📄 conditioneverytime.cpp
字号:
////////////////////////////////////////////////////////////////////////////////// Filename : ConditionEveryTime.cpp// Written By : // Description :////////////////////////////////////////////////////////////////////////////////#include "ConditionEveryTime.h"////////////////////////////////////////////////////////////////////////////////// is satisfied?////////////////////////////////////////////////////////////////////////////////bool ConditionEveryTime::isSatisfied (Creature * pCreature1 , Creature * pCreature2, void* pParam) const throw () { Timeval currentTime; getCurrentTime(currentTime); bool expired = pCreature1 != NULL && pCreature2 == NULL && currentTime > m_NextTurn; //////////////////////////////////////////////////////////////////////////////// // 矫埃捞 檬苞登菌栏搁, 促澜 角青矫埃阑 m_Turn 捞饶肺 犁汲沥茄促. //////////////////////////////////////////////////////////////////////////////// if (expired) { Timeval delay; delay.tv_sec = m_Turn / 10; delay.tv_usec = (m_Turn % 10) * 100000; m_NextTurn = m_NextTurn + delay; } return expired;}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////void ConditionEveryTime::read (PropertyBuffer & propertyBuffer) throw (Error){ try { // read turn m_Turn = propertyBuffer.getPropertyInt("Turn"); } catch (NoSuchElementException & nsee) { throw Error(nsee.toString()); } // set next turn (current time + m_Turn) Timeval delay; delay.tv_sec = m_Turn / 10; delay.tv_usec = (m_Turn % 10) * 100000; getCurrentTime(m_NextTurn); m_NextTurn = m_NextTurn + delay;}//////////////////////////////////////////////////////////////////////////////// // get debug string////////////////////////////////////////////////////////////////////////////////string ConditionEveryTime::toString () const throw () { __BEGIN_TRY StringStream msg; msg << "ConditionEveryTime(" << "Turn:" << (int)m_Turn << ",NextTurn:" << (int)m_NextTurn.tv_sec << "." << (int)m_NextTurn.tv_usec << ")"; return msg.toString(); __END_CATCH}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -