Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_Barter.js
Show All 30 Lines | "buy": { | ||||
"metal": 1.0 | "metal": 1.0 | ||||
}, | }, | ||||
"sell": { | "sell": { | ||||
"wood": 1.0, | "wood": 1.0, | ||||
"stone": 1.0, | "stone": 1.0, | ||||
"metal": 1.0 | "metal": 1.0 | ||||
} | } | ||||
}; | }; | ||||
let cmpBarter = ConstructComponent(SYSTEM_ENTITY, "Barter"); | |||||
AddMock(SYSTEM_ENTITY, IID_Timer, { | AddMock(SYSTEM_ENTITY, IID_Timer, { | ||||
"CancelTimer": id => { timerActivated = false; }, | "CancelTimer": id => { timerActivated = false; }, | ||||
"SetInterval": (ent, iid, funcname, time, repeattime, data) => { | "SetInterval": (ent, iid, funcname, time, repeattime, data) => { | ||||
TS_ASSERT_EQUALS(time, cmpBarter.RESTORE_TIMER_INTERVAL); | TS_ASSERT_EQUALS(time, cmpBarter.RESTORE_TIMER_INTERVAL); | ||||
TS_ASSERT_EQUALS(repeattime, cmpBarter.RESTORE_TIMER_INTERVAL); | TS_ASSERT_EQUALS(repeattime, cmpBarter.RESTORE_TIMER_INTERVAL); | ||||
timerActivated = true; | timerActivated = true; | ||||
return 7; | return 7; | ||||
} | } | ||||
}); | }); | ||||
let cmpBarter = ConstructComponent(SYSTEM_ENTITY, "Barter"); | |||||
// Init | // Init | ||||
TS_ASSERT_EQUALS(cmpBarter.restoreTimer, undefined); | TS_ASSERT_EQUALS(cmpBarter.restoreTimer, undefined); | ||||
TS_ASSERT_UNEVAL_EQUALS(cmpBarter.priceDifferences, { "wood": 0, "stone": 0, "metal": 0 }); | TS_ASSERT_UNEVAL_EQUALS(cmpBarter.priceDifferences, { "wood": 0, "stone": 0, "metal": 0 }); | ||||
AddMock(playerEnt, IID_Player, { | AddMock(playerEnt, IID_Player, { | ||||
"TrySubtractResources": amounts => { | "TrySubtractResources": amounts => { | ||||
sold = amounts[Object.keys(amounts)[0]]; | sold = amounts[Object.keys(amounts)[0]]; | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 135 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator