Compare commits
5 Commits
54050235f0
...
61f98819bc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61f98819bc | ||
|
|
dd6526fb09 | ||
|
|
d5c0d928b6 | ||
|
|
5d2178cd9c | ||
|
|
09d05e950b |
@@ -138,4 +138,6 @@ class Costs():
|
|||||||
Units.KNIGHT: (60, 0, 75, 0),
|
Units.KNIGHT: (60, 0, 75, 0),
|
||||||
Units.SKIRMISHER: (25, 35, 0, 0),
|
Units.SKIRMISHER: (25, 35, 0, 0),
|
||||||
Units.ARCHER: (0, 25, 45, 0),
|
Units.ARCHER: (0, 25, 45, 0),
|
||||||
|
Units.MONK: (0, 0, 100, 0),
|
||||||
|
Units.FISHINGSHIP: (0, 75, 0, 0),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,4 +269,6 @@ class Dependencies():
|
|||||||
Units.KNIGHT: [Ages.CASTLE, Buildings.STABLE],
|
Units.KNIGHT: [Ages.CASTLE, Buildings.STABLE],
|
||||||
Units.SKIRMISHER: [Ages.FEUDAL, Buildings.ARCHERYRANGE],
|
Units.SKIRMISHER: [Ages.FEUDAL, Buildings.ARCHERYRANGE],
|
||||||
Units.ARCHER: [Ages.FEUDAL, Buildings.ARCHERYRANGE],
|
Units.ARCHER: [Ages.FEUDAL, Buildings.ARCHERYRANGE],
|
||||||
|
Units.MONK: [Ages.CASTLE, Buildings.MONASTERY],
|
||||||
|
Units.FISHINGSHIP: [Ages.FEUDAL, Buildings.DOCK],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,12 @@ class Gameplay():
|
|||||||
(initial_task,)))
|
(initial_task,)))
|
||||||
|
|
||||||
|
|
||||||
|
def queue_fishing_ship(self, action_time, initial_task=Tasks.FISH_SHIP_DEEP):
|
||||||
|
self._check_time(action_time)
|
||||||
|
self.actions[action_time].append((self.world.queue_fishing_ship,
|
||||||
|
(initial_task,)))
|
||||||
|
|
||||||
|
|
||||||
def queue_unit(self, action_time, unit):
|
def queue_unit(self, action_time, unit):
|
||||||
self._check_time(action_time)
|
self._check_time(action_time)
|
||||||
self.actions[action_time].append((self.world.queue_unit, (unit,)))
|
self.actions[action_time].append((self.world.queue_unit, (unit,)))
|
||||||
@@ -60,6 +66,12 @@ class Gameplay():
|
|||||||
(old_task, new_task, count,)))
|
(old_task, new_task, count,)))
|
||||||
|
|
||||||
|
|
||||||
|
def get_relic(self, action_time, walking_time=60):
|
||||||
|
self._check_time(action_time)
|
||||||
|
self.actions[action_time].append((self.world.get_relic,
|
||||||
|
(walking_time,)))
|
||||||
|
|
||||||
|
|
||||||
def lure_huntable_with_villager(self,
|
def lure_huntable_with_villager(self,
|
||||||
action_time,
|
action_time,
|
||||||
previous_task,
|
previous_task,
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ class Gather():
|
|||||||
if task in [
|
if task in [
|
||||||
Tasks.IDLE,
|
Tasks.IDLE,
|
||||||
Tasks.BUILD,
|
Tasks.BUILD,
|
||||||
|
Tasks.MONK_IDLE,
|
||||||
Tasks.LURE,
|
Tasks.LURE,
|
||||||
]:
|
]:
|
||||||
return
|
return
|
||||||
@@ -281,6 +282,9 @@ class Gather():
|
|||||||
Tasks.BUILD,
|
Tasks.BUILD,
|
||||||
Tasks.LURE,
|
Tasks.LURE,
|
||||||
Tasks.IDLE,
|
Tasks.IDLE,
|
||||||
|
Tasks.MONK_IDLE,
|
||||||
|
Tasks.MONK_GET_RELIC,
|
||||||
|
Tasks.FISH_SHIP_IDLE,
|
||||||
]:
|
]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -408,7 +412,8 @@ class Gather():
|
|||||||
Buildings.MININGCAMP: {Tasks.GOLD: 4*800,
|
Buildings.MININGCAMP: {Tasks.GOLD: 4*800,
|
||||||
Tasks.STONE: 4*350},
|
Tasks.STONE: 4*350},
|
||||||
Buildings.FARM: {Tasks.FARM: 175},
|
Buildings.FARM: {Tasks.FARM: 175},
|
||||||
#Buildings.DOCK: {Tasks.WOOD: 100},
|
Buildings.DOCK: {Tasks.FISH_SHIP_SHORE: 100,
|
||||||
|
Tasks.FISH_SHIP_DEEP: 225*2},
|
||||||
Buildings.TOWNCENTER: {Tasks.WOOD: 2000,
|
Buildings.TOWNCENTER: {Tasks.WOOD: 2000,
|
||||||
Tasks.GOLD: 4*800,
|
Tasks.GOLD: 4*800,
|
||||||
Tasks.STONE: 4*350,
|
Tasks.STONE: 4*350,
|
||||||
@@ -425,9 +430,9 @@ class Gather():
|
|||||||
Tasks.BOAR: 0,
|
Tasks.BOAR: 0,
|
||||||
Tasks.HUNT: 0,
|
Tasks.HUNT: 0,
|
||||||
Tasks.FARM: 0,
|
Tasks.FARM: 0,
|
||||||
Tasks.FISH_VILLAGER: 0.5,
|
Tasks.FISH_VILLAGER: 0,
|
||||||
Tasks.FISH_SHIP_SHORE: 0.5,
|
Tasks.FISH_SHIP_SHORE: 0,
|
||||||
Tasks.FISH_SHIP_DEEP: 0,
|
Tasks.FISH_SHIP_DEEP: 0.5,
|
||||||
Tasks.FISHTRAP: 0,
|
Tasks.FISHTRAP: 0,
|
||||||
Tasks.WOOD: 0.85,
|
Tasks.WOOD: 0.85,
|
||||||
Tasks.GOLD: 0,
|
Tasks.GOLD: 0,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class Housing():
|
|||||||
|
|
||||||
if required > 0:
|
if required > 0:
|
||||||
pop_space = world.get_population_space()
|
pop_space = world.get_population_space()
|
||||||
if world.get_effective_population() > pop_space + required:
|
if world.get_effective_population() + required > pop_space:
|
||||||
raise YallGotHousedException
|
raise YallGotHousedException
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ class Production():
|
|||||||
Units.KNIGHT: Buildings.STABLE,
|
Units.KNIGHT: Buildings.STABLE,
|
||||||
Units.SKIRMISHER: Buildings.ARCHERYRANGE,
|
Units.SKIRMISHER: Buildings.ARCHERYRANGE,
|
||||||
Units.ARCHER: Buildings.ARCHERYRANGE,
|
Units.ARCHER: Buildings.ARCHERYRANGE,
|
||||||
|
Units.MONK: Buildings.MONASTERY,
|
||||||
|
Units.FISHINGSHIP: Buildings.DOCK,
|
||||||
Research.TOWNWATCH: Buildings.TOWNCENTER,
|
Research.TOWNWATCH: Buildings.TOWNCENTER,
|
||||||
Research.TOWNPATROL: Buildings.TOWNCENTER,
|
Research.TOWNPATROL: Buildings.TOWNCENTER,
|
||||||
Research.TREADMILLCRANE: Buildings.UNIVERSITY,
|
Research.TREADMILLCRANE: Buildings.UNIVERSITY,
|
||||||
|
|||||||
@@ -135,4 +135,6 @@ class Times():
|
|||||||
Units.KNIGHT: 30,
|
Units.KNIGHT: 30,
|
||||||
Units.SKIRMISHER: 22,
|
Units.SKIRMISHER: 22,
|
||||||
Units.ARCHER: 35,
|
Units.ARCHER: 35,
|
||||||
|
Units.MONK: 51,
|
||||||
|
Units.FISHINGSHIP: 40,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,11 +56,14 @@ class Tasks(Enum):
|
|||||||
LURE = auto()
|
LURE = auto()
|
||||||
FARM = auto()
|
FARM = auto()
|
||||||
FISH_VILLAGER = auto()
|
FISH_VILLAGER = auto()
|
||||||
|
FISH_SHIP_IDLE = auto()
|
||||||
FISH_SHIP_SHORE = auto()
|
FISH_SHIP_SHORE = auto()
|
||||||
FISH_SHIP_DEEP = auto()
|
FISH_SHIP_DEEP = auto()
|
||||||
FISHTRAP = auto()
|
FISHTRAP = auto()
|
||||||
WOOD = auto()
|
WOOD = auto()
|
||||||
GOLD = auto()
|
GOLD = auto()
|
||||||
|
MONK_IDLE = auto()
|
||||||
|
MONK_GET_RELIC = auto()
|
||||||
RELIC = auto()
|
RELIC = auto()
|
||||||
TRADECART = auto()
|
TRADECART = auto()
|
||||||
TRADECOG = auto()
|
TRADECOG = auto()
|
||||||
@@ -168,3 +171,5 @@ class Units(Enum):
|
|||||||
KNIGHT = auto()
|
KNIGHT = auto()
|
||||||
SKIRMISHER = auto()
|
SKIRMISHER = auto()
|
||||||
ARCHER = auto()
|
ARCHER = auto()
|
||||||
|
MONK = auto()
|
||||||
|
FISHINGSHIP = auto()
|
||||||
|
|||||||
64
aoe/world.py
64
aoe/world.py
@@ -153,6 +153,30 @@ class World():
|
|||||||
if self.villager_tasks[previous_task] < count:
|
if self.villager_tasks[previous_task] < count:
|
||||||
raise IllegalVillagerMoveException
|
raise IllegalVillagerMoveException
|
||||||
|
|
||||||
|
non_assignable_tasks = [
|
||||||
|
Tasks.MONK_GET_RELIC,
|
||||||
|
Tasks.MONK_IDLE,
|
||||||
|
Tasks.RELIC,
|
||||||
|
Tasks.TRADECART,
|
||||||
|
Tasks.TRADECOG,
|
||||||
|
]
|
||||||
|
|
||||||
|
fishing_tasks = [
|
||||||
|
Tasks.FISH_SHIP_IDLE,
|
||||||
|
Tasks.FISH_SHIP_SHORE,
|
||||||
|
Tasks.FISH_SHIP_DEEP,
|
||||||
|
Tasks.FISHTRAP,
|
||||||
|
]
|
||||||
|
|
||||||
|
if new_task in non_assignable_tasks or \
|
||||||
|
previous_task in non_assignable_tasks:
|
||||||
|
raise IllegalVillagerMoveException
|
||||||
|
|
||||||
|
num_fishing_tasks = (int(new_task in non_assignable_tasks) +
|
||||||
|
int(previous_task in non_assignable_tasks))
|
||||||
|
if num_fishing_tasks == 1:
|
||||||
|
raise IllegalVillagerMoveException
|
||||||
|
|
||||||
if new_task:
|
if new_task:
|
||||||
self.gather.check_gather(self, new_task, count)
|
self.gather.check_gather(self, new_task, count)
|
||||||
self.villager_tasks[new_task] += count
|
self.villager_tasks[new_task] += count
|
||||||
@@ -183,6 +207,32 @@ class World():
|
|||||||
self.assign_villager(task, Tasks.BUILD, count)
|
self.assign_villager(task, Tasks.BUILD, count)
|
||||||
|
|
||||||
|
|
||||||
|
def get_relic(self, walking_time=60):
|
||||||
|
if self.villager_tasks[Tasks.MONK_IDLE] < 1:
|
||||||
|
self.relics_waiting_for_monk.append(walking_time)
|
||||||
|
return
|
||||||
|
|
||||||
|
self.villager_tasks[Tasks.MONK_IDLE] -= 1
|
||||||
|
self.villager_tasks[Tasks.MONK_GET_RELIC] += 1
|
||||||
|
|
||||||
|
update_time = self.current_time + walking_time
|
||||||
|
|
||||||
|
self.events[update_time].append((self._add_relic, ()))
|
||||||
|
|
||||||
|
|
||||||
|
def _add_relic(self):
|
||||||
|
self.villager_tasks[Tasks.MONK_IDLE] += 1
|
||||||
|
self.villager_tasks[Tasks.MONK_GET_RELIC] -= 1
|
||||||
|
self.villager_tasks[Tasks.RELIC] += 1
|
||||||
|
self._get_next_waiting_relic()
|
||||||
|
|
||||||
|
|
||||||
|
def _get_next_waiting_relic(self):
|
||||||
|
if len(self.relics_waiting_for_monk) > 0:
|
||||||
|
walking_time = self.relics_waiting_for_monk.pop()
|
||||||
|
self.get_relic(walking_time)
|
||||||
|
|
||||||
|
|
||||||
def build(self, building, villagers_from, villagers_to, building_tasks=None):
|
def build(self, building, villagers_from, villagers_to, building_tasks=None):
|
||||||
if type(villagers_from) == Tasks:
|
if type(villagers_from) == Tasks:
|
||||||
villagers_from = [villagers_from]
|
villagers_from = [villagers_from]
|
||||||
@@ -359,7 +409,16 @@ class World():
|
|||||||
if thing == Units.VILLAGER:
|
if thing == Units.VILLAGER:
|
||||||
self.villagers += 1
|
self.villagers += 1
|
||||||
self.villager_tasks[Tasks.IDLE] += 1
|
self.villager_tasks[Tasks.IDLE] += 1
|
||||||
|
if not initial_task:
|
||||||
|
initial_task = Tasks.IDLE
|
||||||
self.assign_villager(Tasks.IDLE, initial_task)
|
self.assign_villager(Tasks.IDLE, initial_task)
|
||||||
|
elif thing == Units.MONK:
|
||||||
|
self.villager_tasks[Tasks.MONK_IDLE] += 1
|
||||||
|
self._get_next_waiting_relic()
|
||||||
|
elif thing == Units.FISHINGSHIP:
|
||||||
|
if not initial_task:
|
||||||
|
initial_task = Tasks.FISH_SHIP_IDLE
|
||||||
|
self.villager_tasks[initial_task] += 1
|
||||||
|
|
||||||
|
|
||||||
def _start_producing(self, thing, initial_task):
|
def _start_producing(self, thing, initial_task):
|
||||||
@@ -392,6 +451,10 @@ class World():
|
|||||||
self._queue_thing(Units.VILLAGER, initial_task)
|
self._queue_thing(Units.VILLAGER, initial_task)
|
||||||
|
|
||||||
|
|
||||||
|
def queue_fishing_ship(self, initial_task=Tasks.FISH_SHIP_DEEP):
|
||||||
|
self._queue_thing(Units.FISHINGSHIP, initial_task)
|
||||||
|
|
||||||
|
|
||||||
def _handle_events(self):
|
def _handle_events(self):
|
||||||
for func, args in self.events[self.current_time]:
|
for func, args in self.events[self.current_time]:
|
||||||
func(*args)
|
func(*args)
|
||||||
@@ -437,6 +500,7 @@ class World():
|
|||||||
self.production_available = {b: 0 for b in Buildings}
|
self.production_available = {b: 0 for b in Buildings}
|
||||||
self.production_available[Buildings.TOWNCENTER] = 1
|
self.production_available[Buildings.TOWNCENTER] = 1
|
||||||
self.production_queue = []
|
self.production_queue = []
|
||||||
|
self.relics_waiting_for_monk = []
|
||||||
|
|
||||||
self.current_time = 0
|
self.current_time = 0
|
||||||
self.events = defaultdict(list)
|
self.events = defaultdict(list)
|
||||||
|
|||||||
218
tests/test.py
218
tests/test.py
@@ -10,6 +10,85 @@ from aoe.gameplay import *
|
|||||||
class TestWorld(unittest.TestCase):
|
class TestWorld(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_to_feudal(game):
|
||||||
|
walking = 35 # to match mill and camp
|
||||||
|
final_time = 430 # sufficient time to gather boar and age up
|
||||||
|
|
||||||
|
game.lure_huntable_with_villager(0, Tasks.IDLE, walking)
|
||||||
|
game.build(0, Buildings.MILL, Tasks.IDLE, Tasks.BOAR)
|
||||||
|
game.build(0, Buildings.LUMBERCAMP, Tasks.IDLE, Tasks.BOAR)
|
||||||
|
game.increase_age(300)
|
||||||
|
game.play_until(final_time)
|
||||||
|
return final_time
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_to_castle(game):
|
||||||
|
walking = 1
|
||||||
|
|
||||||
|
current_time = TestWorld.get_to_feudal(game)
|
||||||
|
|
||||||
|
wood_gather_per_60 = 23.4
|
||||||
|
wood_needed = 175 + 150
|
||||||
|
wood_duration = int(wood_needed/(wood_gather_per_60*2) + 1)*60
|
||||||
|
|
||||||
|
boar_amount_no_decay = 340
|
||||||
|
boar_per_60 = 24.6
|
||||||
|
boar_duration = int(boar_amount_no_decay/boar_per_60)*60
|
||||||
|
|
||||||
|
food_needed = 1000
|
||||||
|
boars_needed = int(food_needed/boar_amount_no_decay + 1)
|
||||||
|
|
||||||
|
# we can use infinite-boars cheat if needed
|
||||||
|
for i in range(boars_needed):
|
||||||
|
game.lure_huntable_with_villager(current_time + i*walking,
|
||||||
|
Tasks.IDLE,
|
||||||
|
walking)
|
||||||
|
game.assign_villager(current_time + (i + 1)*walking,
|
||||||
|
Tasks.BOAR,
|
||||||
|
Tasks.IDLE)
|
||||||
|
game.assign_villager(current_time + boars_needed*walking,
|
||||||
|
Tasks.IDLE,
|
||||||
|
Tasks.BOAR)
|
||||||
|
|
||||||
|
game.assign_villager(current_time, Tasks.IDLE, Tasks.WOOD, 2)
|
||||||
|
|
||||||
|
gather_time = max((boar_duration + walking)*boars_needed,
|
||||||
|
wood_duration)
|
||||||
|
|
||||||
|
current_time += gather_time
|
||||||
|
|
||||||
|
# just so I know where they all are (i.e., wood)
|
||||||
|
game.assign_villager(current_time, Tasks.BOAR, Tasks.WOOD)
|
||||||
|
|
||||||
|
game.build(current_time, Buildings.MININGCAMP, Tasks.WOOD, Tasks.WOOD)
|
||||||
|
|
||||||
|
current_time += 35
|
||||||
|
|
||||||
|
game.assign_villager(current_time, Tasks.WOOD, Tasks.GOLD, 3)
|
||||||
|
|
||||||
|
gold_per_60 = 22.8
|
||||||
|
gold_needed = 100
|
||||||
|
gold_duration = int(gold_needed/(gold_per_60*3) + 1)*60
|
||||||
|
|
||||||
|
current_time += gold_duration
|
||||||
|
|
||||||
|
game.build(current_time, Buildings.MARKET, Tasks.GOLD, Tasks.GOLD)
|
||||||
|
game.build(current_time, Buildings.BLACKSMITH, Tasks.GOLD, Tasks.GOLD)
|
||||||
|
|
||||||
|
market_build = 60
|
||||||
|
current_time += market_build
|
||||||
|
|
||||||
|
game.increase_age(current_time)
|
||||||
|
game.assign_villager(current_time, Tasks.GOLD, Tasks.IDLE, 3)
|
||||||
|
|
||||||
|
current_time += 160
|
||||||
|
game.play_until(current_time)
|
||||||
|
|
||||||
|
return current_time
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def equal_to_tolerance(v1, v2, atol):
|
def equal_to_tolerance(v1, v2, atol):
|
||||||
return (abs(v1 - v2) <= atol)
|
return (abs(v1 - v2) <= atol)
|
||||||
@@ -179,3 +258,142 @@ class TestWorld(unittest.TestCase):
|
|||||||
game.build(0, Buildings.FARM, Tasks.IDLE, Tasks.IDLE)
|
game.build(0, Buildings.FARM, Tasks.IDLE, Tasks.IDLE)
|
||||||
with self.assertRaises(MissingDependencyException):
|
with self.assertRaises(MissingDependencyException):
|
||||||
game.play_until(1)
|
game.play_until(1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_housed(self):
|
||||||
|
game = Gameplay()
|
||||||
|
game.queue_villager(0, Tasks.IDLE)
|
||||||
|
game.queue_villager(0, Tasks.IDLE)
|
||||||
|
game.play_until(20)
|
||||||
|
|
||||||
|
with self.assertRaises(YallGotHousedException):
|
||||||
|
game.play_until(25)
|
||||||
|
|
||||||
|
|
||||||
|
def test_gather_boar_without_lure(self):
|
||||||
|
game = Gameplay()
|
||||||
|
game.assign_villager(0, Tasks.IDLE, Tasks.BOAR, 1)
|
||||||
|
game.play_until(20)
|
||||||
|
self.assertResourcesMatch([200, 200, 100, 200], game.world)
|
||||||
|
|
||||||
|
|
||||||
|
def test_gather_boar(self):
|
||||||
|
walking = 20
|
||||||
|
|
||||||
|
game = Gameplay()
|
||||||
|
game.lure_huntable_with_villager(0, Tasks.IDLE, walking)
|
||||||
|
game.assign_villager(walking, Tasks.IDLE, Tasks.BOAR, 2)
|
||||||
|
game.play_until(walking + 60)
|
||||||
|
|
||||||
|
boar_rate_times_60 = 24.6
|
||||||
|
gathered = boar_rate_times_60*3
|
||||||
|
|
||||||
|
self.assertResourcesMatch([200 + gathered, 200, 100, 200], game.world)
|
||||||
|
|
||||||
|
|
||||||
|
def test_gather_boar_limited_no_decay(self):
|
||||||
|
walking = 20
|
||||||
|
|
||||||
|
game = Gameplay()
|
||||||
|
game.lure_huntable_with_villager(0, Tasks.IDLE, walking)
|
||||||
|
game.assign_villager(walking, Tasks.IDLE, Tasks.BOAR, 2)
|
||||||
|
game.play_until(1000)
|
||||||
|
|
||||||
|
boar_total = 340
|
||||||
|
|
||||||
|
self.assertResourcesMatch([200 + boar_total, 200, 100, 200], game.world)
|
||||||
|
|
||||||
|
|
||||||
|
def test_age_increase(self):
|
||||||
|
walking = 35 # to match mill and camp
|
||||||
|
|
||||||
|
game = Gameplay()
|
||||||
|
game.lure_huntable_with_villager(0, Tasks.IDLE, walking)
|
||||||
|
game.build(0, Buildings.MILL, Tasks.IDLE, Tasks.BOAR)
|
||||||
|
game.build(0, Buildings.LUMBERCAMP, Tasks.IDLE, Tasks.BOAR)
|
||||||
|
game.increase_age(300)
|
||||||
|
game.play_until(400)
|
||||||
|
self.assertEqual(Ages.DARK, game.world.age)
|
||||||
|
game.play_until(430)
|
||||||
|
self.assertEqual(Ages.FEUDAL, game.world.age)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_relic_no_monk(self):
|
||||||
|
game = Gameplay()
|
||||||
|
game.get_relic(0, walking_time=10)
|
||||||
|
game.play_until(10 + 500)
|
||||||
|
self.assertResourcesMatch([200, 200, 100, 200], game.world)
|
||||||
|
|
||||||
|
|
||||||
|
def test_monk_get_relic(self):
|
||||||
|
game = Gameplay()
|
||||||
|
|
||||||
|
current_time = TestWorld.get_to_castle(game)
|
||||||
|
|
||||||
|
game.assign_villager(current_time, Tasks.IDLE, Tasks.WOOD, 3)
|
||||||
|
|
||||||
|
# add some long amount of time so we are sure to have enough wood
|
||||||
|
current_time += 500
|
||||||
|
game.build(current_time,
|
||||||
|
Buildings.MONASTERY,
|
||||||
|
Tasks.WOOD,
|
||||||
|
Tasks.WOOD)
|
||||||
|
|
||||||
|
current_time += 40
|
||||||
|
game.assign_villager(current_time, Tasks.WOOD, Tasks.GOLD, 3)
|
||||||
|
|
||||||
|
gold_for_monk = 100
|
||||||
|
gold_per_60 = 22.8
|
||||||
|
gold_duration = int(gold_for_monk/(gold_per_60*3) + 1)*60
|
||||||
|
|
||||||
|
current_time += gold_duration
|
||||||
|
game.queue_unit(current_time, Units.MONK)
|
||||||
|
game.assign_villager(current_time, Tasks.GOLD, Tasks.IDLE, 3)
|
||||||
|
|
||||||
|
game.play_until(current_time)
|
||||||
|
initial_gold = game.world.gather.resources[2]
|
||||||
|
|
||||||
|
current_time += 51
|
||||||
|
game.get_relic(current_time, walking_time=20)
|
||||||
|
|
||||||
|
current_time += 20
|
||||||
|
|
||||||
|
game.play_until(current_time + 60)
|
||||||
|
|
||||||
|
relic_gold_per_60 = 30
|
||||||
|
|
||||||
|
self.assertEqual(initial_gold + relic_gold_per_60,
|
||||||
|
game.world.gather.resources[2])
|
||||||
|
|
||||||
|
|
||||||
|
def test_ship_no_fishing(self):
|
||||||
|
game = Gameplay()
|
||||||
|
|
||||||
|
# just cheat
|
||||||
|
game.world.age = Ages.FEUDAL
|
||||||
|
game.world.gather.resources = [500, 500, 500, 500]
|
||||||
|
game.world._add_building(Buildings.DOCK, {}, {})
|
||||||
|
|
||||||
|
game.queue_fishing_ship(0, Tasks.FISH_SHIP_IDLE)
|
||||||
|
|
||||||
|
training = 40
|
||||||
|
|
||||||
|
game.play_until(training + 60)
|
||||||
|
self.assertResourcesMatch([500, 425, 500, 500], game.world)
|
||||||
|
|
||||||
|
|
||||||
|
def test_ship_deep_fishing(self):
|
||||||
|
game = Gameplay()
|
||||||
|
|
||||||
|
# just cheat
|
||||||
|
game.world.age = Ages.FEUDAL
|
||||||
|
game.world.gather.resources = [500, 500, 500, 500]
|
||||||
|
game.world._add_building(Buildings.DOCK, {}, {})
|
||||||
|
|
||||||
|
game.queue_fishing_ship(0)
|
||||||
|
|
||||||
|
training = 40
|
||||||
|
gathered = 29.4
|
||||||
|
|
||||||
|
game.play_until(training + 60)
|
||||||
|
self.assertResourcesMatch([500 + gathered, 425, 500, 500], game.world)
|
||||||
|
|||||||
Reference in New Issue
Block a user