def updateCard(self, card, id, desc, type): if isinstance(card, cardFactory.ColorCard): cardManager.CardManager().editCard(card, id, desc) print("Updated Color Card") elif isinstance(card, cardFactory.StudentCard): cardManager.CardManager().editCard(card, id, desc) print("Updated Student Card") else: print("method for this type of card not programmed")
def main(): # Initialize all singeltons gameController.GameController() # initialize Game Controller rFIDReader.RFIDReader() # open serial interface manager cardFactory.CardFactory() # initialize card factory manager cardManager.CardManager() # initialize card manager gamePlayModes.GamePlayManager().setGamePlayMode(0) # activate game play mode "simple" cardManager.CardManager().loadConfiguration() # load config from pickle to card manager app = mainGUI.MainGui() # start gui app.pack() app.master.title("ReaFID") app.mainloop()
def getRandomDescription(self): ''' get description of the matching card to update the MainGUI ''' randomNumber = (GameLogic.getRandomNumber(self) - 1) print("random Color Number", randomNumber) card = cardManager.CardManager().getCardByNumber(randomNumber) checkType = type( cardManager.CardManager().getCardByNumber(randomNumber)) # print ("typ: " ,checkType) if (isinstance(card, cardFactory.ColorCard)): # print("getRandomDescription: Color true") receivedCard = card.getColor() else: # print("getRandomDescription: Color false") receivedCard = card.getName() return receivedCard #GameLogic()
def getRandomNumber(self): ''' select a random number - but only valid in the range of available cards ''' cardArraySize = cardManager.CardManager().getSizeCardArray() # print ("cardArraySize:", cardArraySize) if (cardArraySize != 0): validRandomNumber = random.randint(1, cardArraySize) # print ("validRandomNumber:", validRandomNumber) return validRandomNumber else: print("Card Manager is still empty")
def test_openMainGUI(self): # self.myController rFIDReader.RFIDReader() gamePlayModes.GamePlayManager().setGamePlayMode(0) cardFactory.CardFactory() myCardManager = cardManager.CardManager() myCardManager.loadConfiguration() app = mainGUI.MainGui() app.pack() app.master.title("ReaFID") app.mainloop()
def setUp(self): self.myCardFactory = cardFactory.CardFactory() self.card1 = self.myCardFactory.createCard("Color") self.card2 = self.myCardFactory.createCard("Color") self.card3 = self.myCardFactory.createCard("Color") self.card1.setColor("Red") self.card2.setColor("Blue") self.card3.setColor("Green") self.card1.setID("AD B8 57 94") self.card2.setID("B2 FB 30 E9") self.card3.setID("8D F4 61 94") self.myCardManager = cardManager.CardManager() self.myCardManager.addCard(self.card1) self.myCardManager.addCard(self.card2) self.myCardManager.addCard(self.card3)
def deleteCard(self, card): cardManager.CardManager().removeCard(card)
def getCardManager(self): return cardManager.CardManager()
def test_getCard(self): self.myCardManager = cardManager.CardManager() self.foundCard = self.myCardManager.getCardByID("AD B8 57 94") self.assertTrue(type(self.foundCard))
def test_loadStoredConfiguration(self): self.myCardManager = cardManager.CardManager() self.myCardManager.loadConfiguration() self.myCardManager.outputCards() self.assertEqual(self.myCardManager.getSizeCardArray(), 3)
def tearDown(self): cardManager.CardManager().getEmptyManager(self.myCardManager)