Common::Error CineEngine::saveGameState(int slot, const Common::String &desc) { // Load savegame descriptions from index file loadSaveDirectory(); // Set description for selected slot making sure it ends with a trailing zero strncpy(currentSaveName[slot], desc.c_str(), 20); currentSaveName[slot][sizeof(CommandeType) - 1] = 0; // Update savegame descriptions Common::String indexFile = _targetName + ".dir"; Common::OutSaveFile *fHandle = _saveFileMan->openForSaving(indexFile); if (!fHandle) { warning("Unable to open file %s for saving", indexFile.c_str()); return Common::kUnknownError; } fHandle->write(currentSaveName, 10 * 20); delete fHandle; // Save game char saveFileName[256]; sprintf(saveFileName, "%s.%1d", _targetName.c_str(), slot); makeSave(saveFileName); checkDataDisk(-1); return Common::kNoError; }
int DnDCharacter::makeRoll(QString type, QString mod, int bonus){ if(type == "attack") return makeAttack(type, mod,bonus); else if(type == "will" || type == "fortitude" || type == "reflex") return makeSave(type,mod,bonus); else if(type == "None") return die->roll() + getMod(mod) + bonus; else return die->roll() + getValue(type).toInt() + getMod(mod) + bonus; }
// Main Function void _main( void ){ //Create or load savefile SAVE gameState; if(readSave(&gameState)) makeSave(&gameState); writeSave(&gameState); /*just to test whether writing is possible here so the player doesn't spend a long time and lose their progress*/ //Buffer for the text at the bottom of the scoreString = (char*)malloc(60*sizeof(char)); if(scoreString == NULL) exit(ER_MEMORY); //Pause menu pauseMenu = PopupNew(strConv[11], 50); if(pauseMenu == H_NULL) memkill(4, ER_MEMORY); PopupAddText(pauseMenu, -1, "New Game", 1); PopupAddText(pauseMenu, 0, "Options", 2); PopupAddText(pauseMenu,2,"Toggle Animations",5); PopupAddText(pauseMenu,2,"Reset Save Data",6); PopupAddText(pauseMenu, -1, "Exit", 3); PopupAddText(pauseMenu, -1, "About", 4); //Hiscore Name Entry nameBox = DialogNewSimple(140,35); if(nameBox == H_NULL) memkill(3, ER_MEMORY); DialogAddTitle(nameBox,"NEW HISCORE!",BT_OK,BT_NONE); DialogAddRequest(nameBox,3,14,"Name:", 0, 10, 14); //Game Over Entry gameOver = PopupNew("GAME OVER!", 40); if(gameOver == H_NULL) memkill(2, ER_MEMORY); PopupAddText(gameOver,-1,"Try Again",1); PopupAddText(gameOver,-1,"Exit",2); //About Dialouge aboutBox = DialogNewSimple(140,80); if(aboutBox == H_NULL) memkill(1, ER_MEMORY); DialogAddTitle(aboutBox,"ABOUT",BT_OK,BT_NONE); DialogAddText(aboutBox, 3, 13, "2048: A sliding tile puzzle"); DialogAddText(aboutBox, 3, 21, "Ti68k port by Harrison Cook"); DialogAddText(aboutBox, 3, 29, "Original game by Gabriele Cirulli"); DialogAddText(aboutBox, 3, 37, "\"Based on\" 1024 by Veewo Studio"); DialogAddText(aboutBox, 3, 45, "\"Conceptually Similar to\":"); DialogAddText(aboutBox, 3, 52, "Threes by Asher Vollmer"); DialogAddText(aboutBox, 3, 59, "Built using TIGCC"); ClrScr(); FontSetSys(F_8x10); randomize(); short int key; for(;;){ ClrScr(); drawGrid(gameState.grid); sprintf(scoreString, "Score: %lu Hiscore: %lu by %s", gameState.score, gameState.bscore, gameState.name); if(!isGridAvailable(gameState.grid)){ if(gameState.score > gameState.bscore){ DialogDo(nameBox,CENTER,CENTER, gameState.name,NULL); gameState.bscore = gameState.score; FontSetSys(F_8x10); } gameState.score = 0; initGrid(gameState.grid); switch(PopupDo(gameOver,CENTER,CENTER,0)){ case 1: continue; break; default: goto endGame; } } ST_helpMsg(scoreString); nodraw: ST_busy(ST_IDLE); key = ngetchx(); ST_busy(ST_BUSY); ST_helpMsg(scoreString); char move = 4; if(key == KEY_UP) move = UP; else if(key == KEY_RIGHT) move = RIGHT; else if(key == KEY_DOWN) move = DOWN; else if(key == KEY_LEFT) move = LEFT; else if(key == KEY_OFF || key==KEY_ON) //Turn the calculator off during a game. Resume it later off(); else if(key == KEY_ESC){ //Brings up the pause menu switch (PopupDo(pauseMenu,CENTER,CENTER,0)){ case 1: //1. New Game gameState.score = 0; initGrid(gameState.grid); break; //case 2: //2. Options //this is a submenu case 3: //3: Exit endGame: writeSave(&gameState); memkill(0,0); break; case 4: //4: About DialogDo(aboutBox,CENTER,CENTER,NULL,NULL); //Dialog sets the font weirdly, set it back FontSetSys(F_8x10); break; case 5: //1. Toggle Animations gameState.animations = !gameState.animations; break; case 6: //2. Reset Saved Data makeSave(&gameState); break; } } else goto nodraw; if(move < 4){ if(isDirectionAvailable(gameState.grid, move)){ shiftGrid(gameState.grid,move,&gameState.score, gameState.animations); pushNewTile(gameState.grid); } else goto nodraw; } } }