Skip to content

Commit

Permalink
Fix daily quests (#1056)
Browse files Browse the repository at this point in the history
* Not start GameBountiesFetcher genserver and always send an empty list as bounties

* Delete inactive quests behavior and only send 3 daily quests to the users

* Balance quests and make them more reasonable

* add get player

* update player id obtention

* format

---------

Co-authored-by: Manuel Camejo <[email protected]>
  • Loading branch information
Nico-Sanchez and manucamejo authored Jan 24, 2025
1 parent 209bdfa commit 9311555
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 92 deletions.
1 change: 0 additions & 1 deletion apps/arena/lib/arena/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ defmodule Arena.Application do
Arena.Matchmaking.PairMode,
Arena.Matchmaking.QuickGameMode,
Arena.Matchmaking.DeathmatchMode,
Arena.GameBountiesFetcher,
Arena.GameTracker,
Arena.Authentication.GatewaySigner,
# Start a worker by calling: Arena.Worker.start_link(arg)
Expand Down
10 changes: 2 additions & 8 deletions apps/arena/lib/arena/game_updater.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ defmodule Arena.GameUpdater do
use GenServer
alias Arena.Game.Obstacle
alias Arena.Game.Bounties
alias Arena.GameBountiesFetcher
alias Arena.GameTracker
alias Arena.Game.Crate
alias Arena.Game.Effect
Expand Down Expand Up @@ -117,23 +116,18 @@ defmodule Arena.GameUpdater do
{:reply, :not_a_client, state}

player_id ->
bounties =
GameBountiesFetcher.get_bounties()
|> Enum.shuffle()
|> Enum.take(state.game_config.game.bounties_options_amount)

player = Map.get(state.game_state.players, player_id)

response = %{
player_id: player_id,
team: player.aditional_info.team,
game_config: state.game_config,
game_status: state.game_state.status,
bounties: bounties
bounties: []
}

state =
put_in(state, [:game_state, :players, player_id, :aditional_info, :bounties], bounties)
put_in(state, [:game_state, :players, player_id, :aditional_info, :bounties], [])

{:reply, {:ok, response}, state}
end
Expand Down
20 changes: 2 additions & 18 deletions apps/game_backend/lib/game_backend/users.ex
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,7 @@ defmodule GameBackend.Users do

milestone_quest_result = Repo.insert(changeset)

{active_quests_params, remaining_quests} = Enum.split(available_quests, 3)

{inactive_quests_params, _remaining_quests} = Enum.split(remaining_quests, 3)
active_quests_params = Enum.take(available_quests, 3)

active_quests =
Enum.map(active_quests_params, fn
Expand All @@ -765,21 +763,7 @@ defmodule GameBackend.Users do
Repo.insert(changeset)
end)

inactive_quests =
Enum.map(inactive_quests_params, fn
quest_params ->
attrs = %{
user_id: user.id,
quest_id: quest_params.id,
status: "available"
}

changeset = UserQuest.changeset(%UserQuest{}, attrs)

Repo.insert(changeset)
end)

(active_quests ++ inactive_quests ++ [milestone_quest_result])
(active_quests ++ [milestone_quest_result])
|> Enum.find(fn {result, _quest} -> result == :error end)
|> case do
nil -> {:ok, :quests_inserted}
Expand Down
86 changes: 21 additions & 65 deletions apps/game_backend/priv/curse_of_mirra/quests_descriptions.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[
{
"config_id": 1,
"description": "Win three matches with Muflus",
"description": "Win a match with Muflus",
"type": "daily",
"objective": {
"match_tracking_field": "result",
"value": 3,
"value": 1,
"comparison": "greater_or_equal",
"scope": "match"
},
Expand All @@ -23,28 +23,28 @@
],
"reward": {
"currency": "Gold",
"amount": 444
"amount": 200
}
},
{
"config_id": 2,
"description": "Get 44 kills",
"description": "Get 5 kills",
"type": "daily",
"objective": {
"match_tracking_field": "kills",
"value": 44,
"value": 5,
"comparison": "greater_or_equal",
"scope": "day"
},
"conditions": [],
"reward": {
"currency": "Gold",
"amount": 444
"amount": 200
}
},
{
"config_id": 3,
"description": "This is champions of mirra, lose a match",
"description": "Win a match with Uma",
"type": "daily",
"objective": {
"match_tracking_field": "result",
Expand All @@ -53,15 +53,20 @@
"scope": "match"
},
"conditions": [
{
"match_tracking_field": "character",
"value": "uma",
"comparison": "equal"
},
{
"match_tracking_field": "result",
"value": "loss",
"value": "win",
"comparison": "equal"
}
],
"reward": {
"currency": "Gold",
"amount": 444
"amount": 200
}
},
{
Expand Down Expand Up @@ -174,62 +179,13 @@
"amount": 10000
}
},
{
"config_id": 10,
"description": "Finish a match in less than 1 minute",
"type": "daily",
"objective": {
"match_tracking_field": "result",
"value": 1,
"comparison": "greater_or_equal",
"scope": "match"
},
"conditions": [
{
"match_tracking_field": "duration_ms",
"value": 60000,
"comparison": "lesser_or_equal"
}
],
"reward": {
"currency": "Gold",
"amount": 444
}
},
{
"config_id": 11,
"description": "Win three matches with Uma",
"type": "daily",
"objective": {
"match_tracking_field": "result",
"value": 3,
"comparison": "greater_or_equal",
"scope": "match"
},
"conditions": [
{
"match_tracking_field": "character",
"value": "uma",
"comparison": "equal"
},
{
"match_tracking_field": "result",
"value": "win",
"comparison": "equal"
}
],
"reward": {
"currency": "Gold",
"amount": 444
}
},
{
"config_id": 12,
"description": "Win three matches with Valtimer",
"description": "Win a match with Valtimer",
"type": "daily",
"objective": {
"match_tracking_field": "result",
"value": 3,
"value": 1,
"comparison": "greater_or_equal",
"scope": "match"
},
Expand All @@ -247,23 +203,23 @@
],
"reward": {
"currency": "Gold",
"amount": 444
"amount": 200
}
},
{
"config_id": 13,
"description": "Complete 6 Daily Quests",
"description": "Complete all Daily Quests",
"type": "milestone",
"objective": {
"match_tracking_field": "quest",
"value": 6,
"comparison": "greater_or_equal",
"value": 3,
"comparison": "equal",
"scope": "match"
},
"conditions": [],
"reward": {
"currency": "Gold",
"amount": 10000
"amount": 1000
}
}
]

0 comments on commit 9311555

Please sign in to comment.