Queue: +Q from anything, After Q / Skip Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
54f703341e
commit
6e48c72d95
5 changed files with 93 additions and 15 deletions
|
|
@ -145,12 +145,45 @@ class ActionTest(unittest.TestCase):
|
|||
self.assertTrue(game.queue_add(world, p, high, 1, T0).startswith("Needs level"))
|
||||
self.assertIsNone(game.queue_remove(p, 0))
|
||||
self.assertEqual(len(p["queue"]), game.QUEUE_MAX - 1)
|
||||
game.start_action(world, p, "mine_stone", T0)
|
||||
self.assertEqual(p["queue"], [])
|
||||
game.start_action(world, p, "smith_copper_helmet", T0, once=1)
|
||||
game.queue_add(world, p, "smith_copper_legs", 1, T0)
|
||||
game.drop_out(world, p, T0)
|
||||
self.assertEqual(p["queue"], [])
|
||||
game.start_action(world, p, "cut_logs", T0)
|
||||
game.queue_add(world, p, "smith_copper_legs", 1, T0)
|
||||
game.start_action(world, p, "mine_stone", T0) # no make running: starts now
|
||||
self.assertEqual((p["action"]["id"], p["queue"]), ("mine_stone", []))
|
||||
|
||||
def test_start_during_a_make_sets_what_comes_after(self):
|
||||
world, p = self._smith(20)
|
||||
p["bank"]["logs"] = 5
|
||||
game.start_action(world, p, "cut_logs", T0)
|
||||
self.assertIsNone(game.queue_add(world, p, "smith_copper_helmet", 1, T0)) # on an endless action: starts it
|
||||
self.assertEqual((p["action"]["id"], p["action"]["resume"]), ("smith_copper_helmet", "cut_logs"))
|
||||
game.queue_add(world, p, "smith_copper_legs", 1, T0)
|
||||
self.assertIsNone(game.start_action(world, p, "mine_stone", T0))
|
||||
self.assertEqual((p["action"]["id"], p["action"]["resume"]), ("smith_copper_helmet", "mine_stone"))
|
||||
self.assertEqual(len(p["queue"]), 1) # the queue stays
|
||||
summary = game.process_player(world, p, T0 + 500, random.Random(1))
|
||||
self.assertEqual((p["bank"].get("copper_helmet"), p["bank"].get("copper_legs")), (1, 1))
|
||||
self.assertEqual((p["action"]["id"], summary["resumed"]), ("mine_stone", "mine_stone"))
|
||||
|
||||
def test_skip_queue_starts_now(self):
|
||||
world, p = self._smith(20)
|
||||
game.start_action(world, p, "smith_copper_helmet", T0, once=2)
|
||||
game.queue_add(world, p, "smith_copper_legs", 1, T0)
|
||||
game.start_action(world, p, "cut_logs", T0)
|
||||
self.assertIsNone(game.start_action(world, p, "cut_logs", T0 + 5, skip=True))
|
||||
self.assertEqual((p["action"], p["queue"]), ({"id": "cut_logs", "start": T0 + 5}, []))
|
||||
|
||||
def test_then_idle(self):
|
||||
world, p = self._smith(20)
|
||||
game.start_action(world, p, "smith_copper_helmet", T0, once=1)
|
||||
self.assertEqual(p["action"]["resume"], "mine_stone")
|
||||
self.assertIsNone(game.set_then(p, "cut_logs"))
|
||||
self.assertEqual(p["action"]["resume"], "cut_logs")
|
||||
self.assertIsNone(game.set_then(p, None))
|
||||
game.process_player(world, p, T0 + 500, random.Random(1))
|
||||
self.assertIsNone(p["action"])
|
||||
self.assertEqual(game.set_then(p, None), "Not making anything")
|
||||
|
||||
def test_managing_the_queue(self):
|
||||
world, p = self._smith(20)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue