예제 #1
0
 def validify(self):
     from BaseAI import BaseAI
     #if this class is pointing to an object from before the current turn it's probably
     #somewhere else in memory now
     if self.iteration == BaseAI.iteration:
         return True
     for i in BaseAI.serverBoards:
         if i.ID == self.ID:
             self.ptr = i.ptr
             self.iteration = BaseAI.iteration
             return True
     raise ExistentialError()
예제 #2
0
 def validify(self):
     from BaseAI import BaseAI
     #if this class is pointing to an object from before the current turn it's probably
     #somewhere else in memory now
     if self._iteration == BaseAI.iteration:
         return True
     for i in BaseAI.modelVariants:
         if i._id == self._id:
             self._ptr = i._ptr
             self._iteration = BaseAI.iteration
             return True
     raise ExistentialError()
예제 #3
0
    self._id = library.${lowercase(model.name)}GetId(ptr)

%   if model.type == 'Model':
  #\cond
  def validify(self):
    from BaseAI import BaseAI
    #if this class is pointing to an object from before the current turn it's probably
    #somewhere else in memory now
    if self._iteration == BaseAI.iteration:
      return True
    for i in BaseAI.${lowercase(model.plural)}:
      if i._id == self._id:
        self._ptr = i._ptr
        self._iteration = BaseAI.iteration
        return True
    raise ExistentialError()
  #\endcond
%   endif
%  for func in model.functions + model.properties:
  #\
#${func.doc}
  def ${func.name}(self\
%    for arg in func.arguments:
, ${arg.name}\
%    endfor
):
    self.validify()
%    for arg in func.arguments:
%      if isinstance(arg.type, Model):
    if not isinstance(${arg.name}, ${arg.type.name}):
      raise TypeError('${arg.name} should be of [${arg.type.name}]')