Skip to content

Commit d6a849e

Browse files
authored
Merge pull request #18 from Hazurl/state-options
Implement options related methods in State
2 parents b8eddaf + 249ff01 commit d6a849e

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/state.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class State(object):
55

66
def __init__(self, title, description, is_end):
77
self.assets = {}
8+
self.options = []
89
self.title = title
910
self.description = description
1011
self.end = is_end
@@ -34,7 +35,13 @@ def add_sprite(self, sprite, position_x, position_y, scale):
3435
def add_option(self, label, next_state, required, acquired):
3536
"""Add an option, required and acquired are a dictonary with key 'items', 'history', 'stats'
3637
Each of them are a dictionary name to value"""
37-
pass
38+
option = {
39+
'label' : label,
40+
'next_state' : next_state,
41+
'required' : required,
42+
'acquired' : acquired
43+
}
44+
self.options.append(option)
3845

3946

4047
def get_title(self):
@@ -59,14 +66,9 @@ def is_end(self):
5966
return self.end
6067

6168

62-
def get_option_count(self):
63-
"""Return the nuber of option in this state"""
64-
pass
65-
66-
67-
def get_option(self, index):
69+
def get_options(self):
6870
"""Return the option at 'index'"""
69-
pass
71+
return self.options.copy()
7072

7173

7274
def load_state_from_json(json_content):

0 commit comments

Comments
 (0)