Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-463] Levels with cost #477

Draft
wants to merge 12 commits into
base: gh-411-dungeon-supercampaign-scene
Choose a base branch
from

Conversation

ncontinanza
Copy link
Collaborator

@ncontinanza ncontinanza commented May 31, 2024

Closes #463

Motivation

We need to adapt the client to the levels having a cost in the Dungeon supercampaign.

Summary of changes

  • Show a pop up error if the user doesn't have enough Supplies to play a Dungeon level.
  • Display a level's cost in the line up scene.
  • Dynamically decide which currency to display in the header of the line up scene. Supplies will be shown in a Dungeon level, and Gems in a Main Campaign one.

How has this been tested?

  1. Start the game with its backend branch, and go to the dungeon battles.
  2. Pick the first level and advance to the line up scene. Make sure you can see 5 Supplies in the header (represented with a hammer, by now), and that the cost of the level is shown right above the Battle button (the cost in Supplies is equal to the level number, so for the first level the cost should be 1 Supply).
  3. Play the first level and go back to the line up scene check that the Supplies amount has decreased in the header. If you won the battle, make sure that the level's cost increased. Also, you shouldn't be able to start a battle if you exceed the limit of units (it's 1 for the first levels of this campaign).
  4. Go to the Main Campaign levels, and check that you see Gems in the header of the line up scene and no costs above the Battle button.

Disclaimer: In order to win the first dungeon levels and test some of the available levels in the campaign, you may need to get some upgrades for your units. Follow these steps to do so:

  1. Get your user id. It's probably logged in the client's console, or you can get from the backend by running: user = Champions.Users.get_user_by_username(your_username).
  2. Give some pearls to your user, so you can afford the upgrades: GameBackend.Users.Currencies.add_currency_by_name_and_game(user.id, "Pearls", 2, 1000)
  3. Get the available upgrades: GameBackend.Repo.all(GameBackend.Users.Upgrade)
  4. Look for the "HP Upgrade 1" id in the previous response and buy it: Champions.Users.purchase_dungeon_upgrade(user.id, upgrade1_id)
  5. Repeat for the "HP Upgrade 2": Champions.Users.purchase_dungeon_upgrade(user.id, upgrade2_id)

With this, you should be able to play and win the first Dungeon levels.

Test additions / changes

List tests added/updated.

Checklist

  • I have tested the changes locally.
  • I self-reviewed the changes on GitHub, line by line.
  • Tests have been added/updated.
  • This change requires new documentation.
    • Documentation has been added/updated.
  • I have tested the changes in another devices.
    • Tested in iOS.
    • Tested in Android.

@ncontinanza ncontinanza changed the base branch from main to gh-411-dungeon-supercampaign-scene June 3, 2024 15:42
@ncontinanza ncontinanza marked this pull request as ready for review June 4, 2024 18:05
@ncontinanza ncontinanza added the Waiting on PR Use this tag to alert reviewers that this PR shouldn't be merged until another one is merged first label Jun 4, 2024
@ncontinanza ncontinanza marked this pull request as draft June 4, 2024 18:20
@lotuuu
Copy link
Collaborator

lotuuu commented Jun 4, 2024

Found this error when playing the first level of the Main Campaign with all my units:

InvalidOperationException: Sequence contains no matching element
System.Linq.Enumerable.Single[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) (at <fd6f320ff35f42c8ae05f94a708e9899>:0)
BattleManager.SetUpInitialState (Protobuf.Messages.BattleResult battleResult) (at Assets/Scripts/Battle/BattleManager.cs:99)
BattleManager+<Battle>d__11.MoveNext () (at Assets/Scripts/Battle/BattleManager.cs:81)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/Coroutines.cs:17)

It did not happen when i fought with only 1. It also only seems to happen when I play a level with 1 unit first, and then go back to 6.
Screenshot 2024-06-04 at 6 14 38 PM

@lotuuu
Copy link
Collaborator

lotuuu commented Jun 4, 2024

Also, when I win a dungeon level the app crashes because it does not know the currency rewards

Currency brought from the backend not found in client: 4* Shards
UnityEngine.Debug:LogError (object)
SocketConnection:CreateUserFromData (Protobuf.Messages.User,System.Collections.Generic.List`1<Character>) (at Assets/Scripts/BackendConnection/SocketConnection.cs:152)
SocketConnection:AwaitGetUserResponse (byte[],System.Action`1<User>) (at Assets/Scripts/BackendConnection/SocketConnection.cs:375)
SocketConnection/<>c__DisplayClass20_0:<GetUser>b__0 (byte[]) (at Assets/Scripts/BackendConnection/SocketConnection.cs:339)
NativeWebSocket.WebSocket:DispatchMessageQueue () (at Assets/WebSocket/WebSocket.cs:640)
SocketConnection:Update () (at Assets/Scripts/BackendConnection/SocketConnection.cs:44)

Screenshot 2024-06-04 at 6 26 14 PM

@lotuuu
Copy link
Collaborator

lotuuu commented Jun 4, 2024

Some of these errors might be from #478

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting on PR Use this tag to alert reviewers that this PR shouldn't be merged until another one is merged first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Levels with cost in the client
2 participants