API correction & mcp validation
This commit is contained in:
@@ -100,7 +100,7 @@ class Game(Serializable):
|
||||
def add_event(self, new_event:Event):
|
||||
self.events.append(new_event)
|
||||
self.update_turn_order()
|
||||
self.turn_idx = 0
|
||||
self.turn_idx = 0
|
||||
|
||||
def check_turn_ended(self):
|
||||
if self.turn_idx == len(self.turn_order)-1:
|
||||
@@ -205,12 +205,31 @@ class Game(Serializable):
|
||||
if turn_finished:
|
||||
self.update_turn_order()
|
||||
|
||||
def simple_action(self, src:str, description:str):
|
||||
def simple_action(self, src:str, stat:Stat, difficulty:int, roll:int, description:str):
|
||||
if not self.is_turn_coherent(src):
|
||||
raise ReferenceError(f"Entity #{src} tried performing an action while it was #{self.turn_order[self.turn_idx]}'s turn!")
|
||||
|
||||
turn_finished = self.get_current_event().perform_action(TurnAction.BASIC, src, description=description)
|
||||
src_entity = self.get_entity(src)
|
||||
stat_boost = 0 # Between 0 and 5
|
||||
match(stat):
|
||||
case Stat.STRENGTH:
|
||||
stat_boost = src_entity.get_strength() / 4
|
||||
case Stat.INTELLIGENCE:
|
||||
stat_boost = src_entity.get_intelligence() / 4
|
||||
case Stat.DEXTERITY:
|
||||
stat_boost = src_entity.get_dexterity() / 4
|
||||
case Stat.WISDOM:
|
||||
stat_boost = src_entity.get_wisdom() / 4
|
||||
case Stat.CHARISMA:
|
||||
stat_boost = src_entity.get_charisma() / 4
|
||||
test_result = roll + stat_boost
|
||||
action_performed = difficulty <= test_result
|
||||
|
||||
additional_info = f", (Test difficulty: {difficulty}, Player roll: {test_result})"
|
||||
|
||||
turn_finished = self.get_current_event().perform_action(TurnAction.BASIC, src, description=description+additional_info)
|
||||
self.turn_idx += 1
|
||||
if turn_finished:
|
||||
self.update_turn_order()
|
||||
#TODO: Add State Summary as Resource?
|
||||
|
||||
return action_performed, test_result
|
||||
Reference in New Issue
Block a user