void CardDynamite::play() { if (gameCycle()->isDraw()) { assertOnTable(); owner()->predrawCheck(PredrawCheck); gameCycle()->checkDeck(owner(), this, *CardDynamite::checkDynamite, this); return; } else { gameCycle()->assertTurn(); assertInHand(); if (owner()->hasIdenticalCardOnTable(this)) { throw TwoSameOnTableException(); } gameTable()->playerPlayCardOnTable(this); } }
void CharacterSidKetchum::useAbility(QList<PlayingCard*> cards) { if (cards.size() != 2) throw BadCardException(); foreach (PlayingCard* card, cards) { if (card->owner() != mp_player || card->pocket() != POCKET_HAND) throw BadCardException(); } if (gameCycle().gamePlayState() == GAMEPLAYSTATE_TURN && gameCycle().currentPlayer() == mp_player) { notifyAbilityUse(); foreach (PlayingCard* card, cards) { gameTable().playerDiscardCard(card); }
void CharacterKitCarlson::respondCard(PlayingCard* targetCard) { if (targetCard->pocket() != POCKET_SELECTION) throw BadCardException(); gameTable().playerPickFromSelection(mp_player, targetCard); if (gameTable().selection().size() == 1) { gameCycle().unsetResponseMode(); gameTable().undrawFromSelection(gameTable().selection()[0]); Q_ASSERT(gameTable().selection().size() == 0); } }
void CharacterKitCarlson::draw(bool specialDraw) { if (specialDraw) { notifyAbilityUse(); gameTable().drawIntoSelection(3, mp_player); Q_ASSERT(gameTable().selection().size() == 3); gameCycle().setResponseMode(this, mp_player); } else { CharacterBase::draw(0); } }
void CardTaker::play(PlayingCard* targetCard) { gameCycle()->assertTurn(); assertInHand(); Player* o = owner(); if (m_type == Panic) { /* distance check */ if (game()->getDistance(owner(), targetCard->owner()) > 1) throw PlayerOutOfRangeException(); gameCycle()->setCardEffect(1); gameTable()->playerPlayCard(this, targetCard); gameTable()->playerStealCard(o, targetCard); gameCycle()->setCardEffect(0); } else { gameCycle()->setCardEffect(1); gameTable()->playerPlayCard(this, targetCard); gameTable()->cancelCard(targetCard, o); gameCycle()->setCardEffect(0); } }
void CardTaker::play(Player* targetPlayer) { gameCycle()->assertTurn(); assertInHand(); /* allow steel from himself only if has more than one card in hand */ if (owner() == targetPlayer && owner()->handSize() < 2) throw BadTargetPlayerException(); PlayingCard* targetCard; do { targetCard = targetPlayer->getRandomCardFromHand(); } while (targetCard == this); // pick other than this card if (targetCard == 0) throw BadTargetPlayerException(); play(targetCard); }
Common::Error Sword2Engine::run() { // Get some falling RAM and put it in your pocket, never let it slip // away _debugger = NULL; _sound = NULL; _fontRenderer = NULL; _screen = NULL; _mouse = NULL; _logic = NULL; _resman = NULL; _memory = NULL; initGraphics(640, 480, true); _screen = new Screen(this, 640, 480); // Create the debugger as early as possible (but not before the // screen object!) so that errors can be displayed in it. In // particular, we want errors about missing files to be clearly // visible to the user. _debugger = new Debugger(this); _memory = new MemoryManager(this); _resman = new ResourceManager(this); if (!_resman->init()) return Common::kUnknownError; _logic = new Logic(this); _fontRenderer = new FontRenderer(this); _sound = new Sound(this); _mouse = new Mouse(this); registerDefaultSettings(); readSettings(); initStartMenu(); // During normal gameplay, we care neither about mouse button releases // nor the scroll wheel. setInputEventFilter(RD_LEFTBUTTONUP | RD_RIGHTBUTTONUP | RD_WHEELUP | RD_WHEELDOWN); setupPersistentResources(); initialiseFontResourceFlags(); if (_features & GF_DEMO) _logic->writeVar(DEMO, 1); else _logic->writeVar(DEMO, 0); if (_saveSlot != -1) { if (saveExists(_saveSlot)) restoreGame(_saveSlot); else { RestoreDialog dialog(this); if (!dialog.runModal()) startGame(); } } else if (!_bootParam && saveExists() && !isPsx()) { // Initial load/restart panel disabled in PSX int32 pars[2] = { 221, FX_LOOP }; // version because of missing panel resources bool result; _mouse->setMouse(NORMAL_MOUSE_ID); _logic->fnPlayMusic(pars); StartDialog dialog(this); result = (dialog.runModal() != 0); // If the game is started from the beginning, the cutscene // player will kill the music for us. Otherwise, the restore // will either have killed the music, or done a crossfade. if (shouldQuit()) return Common::kNoError; if (result) startGame(); } else startGame(); _screen->initialiseRenderCycle(); while (1) { _debugger->onFrame(); // Handle GMM Loading if (_gmmLoadSlot != -1) { // Hide mouse cursor and fade screen _mouse->hideMouse(); _screen->fadeDown(); // Clean up and load game _logic->_router->freeAllRouteMem(); // TODO: manage error handling restoreGame(_gmmLoadSlot); // Reset load slot _gmmLoadSlot = -1; // Show mouse _mouse->addHuman(); } KeyboardEvent *ke = keyboardEvent(); if (ke) { if ((ke->kbd.hasFlags(Common::KBD_CTRL) && ke->kbd.keycode == Common::KEYCODE_d) || ke->kbd.ascii == '#' || ke->kbd.ascii == '~') { _debugger->attach(); } else if (ke->kbd.hasFlags(0) || ke->kbd.hasFlags(Common::KBD_SHIFT)) { switch (ke->kbd.keycode) { case Common::KEYCODE_p: if (isPaused()) { _screen->dimPalette(false); pauseEngine(false); } else { pauseEngine(true); _screen->dimPalette(true); } break; #if 0 // Disabled because of strange rumors about the // credits running spontaneously every few // minutes. case Common::KEYCODE_c: if (!_logic->readVar(DEMO) && !_mouse->isChoosing()) { ScreenInfo *screenInfo = _screen->getScreenInfo(); _logic->fnPlayCredits(NULL); screenInfo->new_palette = 99; } break; #endif default: break; } } } // skip GameCycle if we're paused if (!isPaused()) { _gameCycle++; gameCycle(); } // We can't use this as termination condition for the loop, // because we want the break to happen before updating the // screen again. if (shouldQuit()) break; // creates the debug text blocks _debugger->buildDebugText(); _screen->buildDisplay(); } return Common::kNoError; }
void CharacterJesseJones::useAbility(Player* targetPlayer) { mp_targetPlayer = targetPlayer; gameCycle().draw(mp_player, 1); }
void CharacterKitCarlson::useAbility() { gameCycle().draw(mp_player, 1); }