1
\$\begingroup\$

I am creating a game for Android/iOS. The game has a server that communicates with my appengine database. I want to implement daily quests as motivation for the players to return every day, but I need some help on how create a smart solution for this.

So far this is my thought process:

1 - Randomly pick a quest from the DailyQuests table

DailyQuests
ID | Quest                |Goal
1  | Win 3 games in a row | 3
2  | Win 2 rounds of "ex" | 2
...

2 - Add entity "q_progress" (maybe q_ID) to a table storing user stats

3 - Display Quest and progress userStats.q_progress / dailyQuests.goal

4 - After a game (consisting of 5 rounds Bo5) is finished - Save the progress somehow. How do I keep track of consecutive wins? how do I save the progress if the quest has some specific requirement like "win 2 rounds of "ex""

Is the only way to do an if-statement for like quest-ID after each game is finished? Like:

if(q_id == 1){
    consecutiveWins += 1;
    userStats.saveProgress(consecutiveWins);
}
else if(q_id == 2){
    rockDodgerWins += 1
    userStats.saveProgress(rockDodgerWins);
}
...

I feel like this is highly unpractical and might not even work in practice if I really think about it, I only bring it up to maybe give a better view of where my head is at right now.

I don't need any code or anything like that, just someone who is smarter than me that might have experience with something similar or can think of a smart way to accomplish what I need.

\$\endgroup\$
1

2 Answers 2

1
\$\begingroup\$

You could make your list of if-statements much shorter by storing the game type id as well.

for (i = 0; i < quests.length; i++) {
  if (q_id == i) {
    wins += 1;
    // Save consecutive wins for a certain mini-game, i is the id and wins is the amount of wins
    userStats.saveProgress(i, wins);
  }
}

Basically, the code above loops through all game types and saves the wins. You should probably access userStats like userStats.load(gameType); and it should return the amount of wins.

\$\endgroup\$
0
\$\begingroup\$

if you just want to save the progress and keep track of it, i would assume you are storing the user stats in the database on the server. Take advantage of this, since if you store it in the database, in a separate table, you can store progress for everyone and reset it every day by clearing out the 1 table.

In the code you could use something like this:

if(goalUpdate){

// increment wins in database
userStats.saveProgress(1,q_id); // 1 isn't necessary, but useful for items

}

Then lets say for the saveProgress() function, you do something like:

// qId is just used to pass the current q_ID the player completed, i is optional
saveProgress(int i, var qId){ // var means whatever variable you need, or C# var

  if(qId = userData.q_ID){ // check if quest completed was for daily quest
    // if statement is only needed if you didn't check before now
    currentWins += i;
  }

saveUserData(); // save all or part of userData to store currentWins for q_ID

checkProgress(currentWins, qId); // check if goal is met, if so run function to complete

}

That will hopefully give you an idea how to handle it, but just remember when the game loads to initalize or load the userData with the Daily Quest variables. If you initialize it, that would be the best time to create a random Daily Quest for the player.

For clearing the database table, i would just setup something on the server to at a specific time every night to run a database script to clear the 1 table, so it is blank.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .