本文整理匯總了Python中statemachine.StateMachine.set_current_state方法的典型用法代碼示例。如果您正苦於以下問題:Python StateMachine.set_current_state方法的具體用法?Python StateMachine.set_current_state怎麽用?Python StateMachine.set_current_state使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類statemachine.StateMachine
的用法示例。
在下文中一共展示了StateMachine.set_current_state方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Miner
# 需要導入模塊: from statemachine import StateMachine [as 別名]
# 或者: from statemachine.StateMachine import set_current_state [as 別名]
class Miner(BaseGameEntity):
def __init__(self, name):
self.name = name
self.location = None
self.gold = 0
self.fatigue = 0
self.thirsty = 0
self.fsm = StateMachine(self)
self.fsm.set_current_state(states.GoHomeAndSleepTilRested())
self.pocket_limit = 10
self.thirsty_limit = 10
self.fatigue_limit = 10
def __repr__(self):
return '<Miner {0}>'.format(self.name)
def change_location(self, location):
self.location = location
def is_pocket_full(self):
return self.gold >= self.pocket_limit
def add_gold_carried(self, n):
self.gold += n
def increase_fatigue(self):
self.fatigue += 1
self.thirsty += 1
def is_thirsty(self):
return self.thirsty >= self.thirsty_limit
示例2: Wife
# 需要導入模塊: from statemachine import StateMachine [as 別名]
# 或者: from statemachine.StateMachine import set_current_state [as 別名]
class Wife(BaseGameEntity):
def __init__(self, name):
self.name = name
self.fsm = StateMachine(self)
self.fsm.set_current_state(states.DoHouseWork())
self.fsm.set_global_state(states.WifeGlobalState())
def update(self):
self.fsm.update()
def handle_msg(self, sender, msg):
return self.fsm.handle_message(sender, self, msg)