def test_choices_sanity_check_5(self): """ Test with a choice without link :return: """ with self.assertRaises(Exception): Node(id="1", text=DOG_TO_STR, choices=[Choice("1", DOG_TO_STR, [])], effect=lambda account, dog: None).choices_sanity_check()
def test_choices_sanity_check_2(self): """ Test with one choice :return: """ self.assertTrue( Node(id="1", text=DOG_TO_STR, choices=[Choice("1", DOG_TO_STR, [NodeLink("1", 1)])], effect=lambda account, dog: None).choices_sanity_check())
def test_choices_sanity_check_1(self): """ Test with choices = empty list :return: """ self.assertTrue( Node(id="1", text=DOG_TO_STR, choices=[], effect=lambda account, dog: None).choices_sanity_check())
def test_choices_sanity_check_4(self): """ Test with choices = two same choice ids :return: """ with self.assertRaises(Exception): Node(id="1", text=DOG_TO_STR, choices=[ Choice("1", DOG_TO_STR, [NodeLink("1", 1)]), Choice("1", DOG_TO_STR, [NodeLink("1", 1)]) ], effect=lambda account, dog: None).choices_sanity_check()
from main.utils.story.effect import fitness_cookie_update, magic_bone_update, tennis_ball_update from main.utils.story.node import Node, NodeLink, Choice START_SQUIRREL: str = 'START_SQUIRREL' SQUIRREL_STORY_NODES: [Node] = [ Node(id=START_SQUIRREL, text=lambda dog: dog.name + " spot a squirrel in a tree and start barking!", choices=[ Choice("0", lambda dog: "Woof wooOOoof wooof!!!", [ NodeLink("squirrel_drop_cookie", 3), NodeLink("squirrel_steal_cookie", 1) ]), Choice("1", lambda dog: "Stop barking!", [ NodeLink("keep_walking", 9), NodeLink("squirrel_steal_cookie", 1) ]) ]), Node(id="squirrel_drop_cookie", text=lambda dog: "The squirrel is afraid by " + dog.name + " and drop a cookie!", effect=lambda account, dog: fitness_cookie_update(account, 1)), Node( id="squirrel_steal_cookie", text=lambda dog: "Oh no! It was a diversion! Meanwhile another squirrel stole a cookie from your home!", effect=lambda account, dog: fitness_cookie_update(account, -1)), Node(id="keep_walking", text=lambda dog: "You and " + dog.name + " keep walking.") ]
from typing import Dict from main.utils.story.effect import fitness_cookie_update from main.utils.story.graphs.anubis import ANUBIS_STORY_NODES, START_ANUBIS from main.utils.story.graphs.squirrel import START_SQUIRREL, SQUIRREL_STORY_NODES from main.utils.story.node import Node, NodeLink, Choice START_WALK_NODE: str = "START_WALK" STORY_NODES: [Node] = [ Node( id=START_WALK_NODE, text=lambda dog: "What a beautiful day for a walk with " + dog.name + "!", choices=[ Choice("0", lambda dog: "Yes!", [ NodeLink(START_SQUIRREL, 1), NodeLink(START_ANUBIS, 7) ]) ] ) ] STORY_NODES += ANUBIS_STORY_NODES STORY_NODES += SQUIRREL_STORY_NODES def build_story_graph() -> Dict[str, Node]: ret: Dict[str, Node] = {} for node in STORY_NODES: ret[node.id] = node return ret
from main.utils.story.effect import fitness_cookie_update, magic_bone_update, tennis_ball_update from main.utils.story.node import Node, NodeLink, Choice START_CAVERN: str = 'START_CAVERN' CAVERN_STORY_NODES: [Node] = [ Node(id="cavern_found", text=lambda dog: "As you're walking with " + dog.name + " you notice a cavern on the side of the road.", choices=[ Choice("0", lambda dog: "Enter", [NodeLink("cavern_2_1", 1)]) ]), Node(id="cavern_1_1", text=lambda dog: "You are in a cavern.", choices=[ Choice("0", lambda dog: "Go North", [NodeLink("cavern_1_2", 1)]), Choice("1", lambda dog: "Go East", [NodeLink("cavern_2_1", 1)]) ]), Node( id="cavern_2_1", text=lambda dog: "You are in a cavern. A sign says 'Welcome, or not'.", choices=[ Choice("0", lambda dog: "Go North", [NodeLink("cavern_2_2", 1)]), Choice("1", lambda dog: "Go East", [NodeLink("cavern_3_1", 1)]), Choice("2", lambda dog: "Go West", [NodeLink("cavern_1_1", 1)]) ]), Node(id="cavern_3_1", text=lambda dog: "You are in a cavern.", choices=[ Choice("0", lambda dog: "Go North", [NodeLink("cavern_3_2", 1)]), Choice("1", lambda dog: "Go West", [NodeLink("cavern_2_1", 1)])