# -*- coding: utf-8 # Copyright 2006 by Meelis Mets from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import BooleanField, ImageField, StringField from Products.Archetypes.public import BooleanWidget, ImageWidget, StringWidget, SelectionWidget from Products.Archetypes.public import BaseContent, registerType from Globals import InitializeClass from Products.CMFCore.utils import getToolByName from AccessControl import ClassSecurityInfo, Unauthorized from config import PROJECT_NAME from BaseGame import BaseGame schema = BaseGame.schema.copy() + Schema(( )) #schema.delField('multipleChoice') #schema.delField('answerRequired') #schema.delField('time') #schema.moveField('time', pos='bottom') #class RoboRunFunctions: # """ Functions that are needed to run flower task in test view""" # def saveFlowerTask(self,REQUEST): # """ saving data """ # answer=REQUEST.get('current_array') # current = self.getCurrentSheet() # current_id = current.id # if answer != None and answer != "": # answer = answer.split(",") # rc = current.getRightChoice() # if int(answer[0])==rc[0] and int(answer[1])==rc[1]: # rca = 2 # else: # rca = 1 # answers = {'choice':rca} # print "datasse l2hevad "+str(current_id)+" ja "+str(answers) # self.setDataToDatabase(current_id,answers) # self.setCurrentPage() # else: # return self.REQUEST.RESPONSE.redirect(self.absolute_url()+'?error=true') # self.submitToTheNextPage(REQUEST) class RoboRun(BaseGame): """ RoboRun Game""" meta_type = "RoboRun" archetype_name = "Robo Run" global_allow = 0 exclude_from_nav = True filter_content_types = True allowed_content_types = () security = ClassSecurityInfo() schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/robo_run', 'permissions': ('View',), }, { 'id':'edit', 'name':'Configuration', 'action':'string:${object_url}/base_edit', 'permissions': ('Modify portal content',), }, { 'id':'create', 'name':'Create', 'action':'string:${object_url}/robo_run_edit', 'permissions': ('Modify portal content',), }, { 'id':'messages', 'name':'Messages', 'action':'string:${object_url}/game_messages', 'permissions': ('Modify portal content',), }, { 'id':'metadata', 'name':'Info', 'action':'string:${object_url}/base_metadata', 'permissions': ('View',), } ) def __init__(self, id): self.id = id self.landscape = [] self.batteries = [] def getLandscape(self): """gl""" if not hasattr(self, 'landscape'): self.landscape = [] return self.landscape def setLandscape(self,lx,ly): """sl""" self.landscape.append([lx,ly]) self.p_changed = 1 def delLandscape(self,lx,ly): """sl""" newlan = [] for lan in self.landscape: if (lan!=[lx,ly]): newlan.append(lan) self.landscape = newlan self.p_changed = 1 def getBatteries(self): """gl""" if not hasattr(self, 'batteries'): self.batteries = [] print self.batteries return self.batteries def setBatteries(self,bx,by,bt): """sl""" self.batteries.append([bx,by,bt]) self.p_changed = 1 def delBatteries(self,bx,by): """sl""" newbat = [] for bat in self.batteries: if (bat[0]==bx and bat[1]==by): pass else: newbat.append(bat) self.batteries = newbat self.p_changed = 1 def delObjects(self, ox, oy): """deleting objects""" self.delLandscape(ox,oy) self.delBatteries(ox,oy) def getRoboData(self): """dl""" return [self.getLandscape(),self.getBatteries(),self.getGameMessages()] def getMyBestScore(self): """best score""" return 0 registerType(RoboRun, PROJECT_NAME)