Skip to content

Commit

Permalink
Fixed cli tx_set_card_rarity
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Oct 6, 2023
1 parent f61cb36 commit e00a3c5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions scripts/migrate_with_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@


# delete all sets # TODO REMOVE THIS PART ONCE EVERYTHING IS FINE
print(old_dict["app_state"]["cardchain"]["sets"])
old_dict["app_state"]["cardchain"]["sets"] = []
#print(old_dict["app_state"]["cardchain"]["sets"])
#old_dict["app_state"]["cardchain"]["sets"] = []


params = new_dict["app_state"]["cardchain"]["params"]
Expand Down
16 changes: 6 additions & 10 deletions x/cardchain/client/cli/tx_set_card_rarity.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cli

import (
"github.com/DecentralCardGame/cardobject/cardobject"
"fmt"
"strconv"

"github.com/DecentralCardGame/Cardchain/x/cardchain/types"
Expand All @@ -10,6 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/spf13/cast"
"github.com/spf13/cobra"
"golang.org/x/exp/maps"
)

var _ = strconv.Itoa(0)
Expand All @@ -28,17 +29,12 @@ func CmdSetCardRarity() *cobra.Command {
if err != nil {
return err
}
rar, err := strconv.Atoi(args[2])
if err != nil {
return err
rar, found := types.CardRarity_value[args[2]]
if (!found) {
return fmt.Errorf("Rarity has to be in %s", maps.Keys(types.CardRarity_value))
}
argRarity := types.CardRarity(rar)

rarity := cardobject.Rarity(argRarity)
err = rarity.ValidateType(cardobject.Card{})
if err != nil {
return err
}
argRarity := types.CardRarity(rar)

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions x/cardchain/keeper/msg_server_open_booster_pack.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"fmt"
"context"
"math/rand"

Expand Down Expand Up @@ -41,6 +42,7 @@ func (k msgServer) OpenBoosterPack(goCtx context.Context, msg *types.MsgOpenBoos
cleanedRatios[idx] = ratio
}
}
fmt.Printf("%s", rarityNums)

for idx, num := range creator.BoosterPacks[msg.BoosterPackId].RaritiesPerPack {
for i := 0; i < int(num); i++ {
Expand Down Expand Up @@ -74,6 +76,7 @@ func (k msgServer) OpenBoosterPack(goCtx context.Context, msg *types.MsgOpenBoos
func (k Keeper) getCardRaritiesInSet(ctx sdk.Context, set *types.Set) (rarityNums [5][]uint64) {
for _, cardId := range set.Cards {
card := k.Cards.Get(ctx, cardId)
fmt.Println(card.Rarity)
rarityNums[int(card.Rarity)] = append(rarityNums[int(card.Rarity)], cardId)
}
return
Expand Down

0 comments on commit e00a3c5

Please sign in to comment.