Skip to content

Commit

Permalink
feat(#237): Added Proven status to be set to true
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Dec 15, 2024
1 parent 52f6060 commit 552eb88
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
20 changes: 20 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33484,6 +33484,8 @@ paths:
imageId:
type: string
format: uint64
name:
type: string
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -33545,6 +33547,8 @@ paths:
imageId:
type: string
format: uint64
name:
type: string
image:
type: string
format: byte
Expand Down Expand Up @@ -33608,6 +33612,8 @@ paths:
imageId:
type: string
format: uint64
name:
type: string
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -33665,6 +33671,8 @@ paths:
imageId:
type: string
format: uint64
name:
type: string
image:
type: string
format: byte
Expand Down Expand Up @@ -69184,6 +69192,8 @@ definitions:
imageId:
type: string
format: uint64
name:
type: string
DecentralCardGame.cardchain.cardchain.EncounterWithImage:
type: object
properties:
Expand All @@ -69209,6 +69219,8 @@ definitions:
imageId:
type: string
format: uint64
name:
type: string
image:
type: string
format: byte
Expand Down Expand Up @@ -69861,6 +69873,8 @@ definitions:
imageId:
type: string
format: uint64
name:
type: string
DecentralCardGame.cardchain.cardchain.QueryQEncounterWithImageResponse:
type: object
properties:
Expand Down Expand Up @@ -69889,6 +69903,8 @@ definitions:
imageId:
type: string
format: uint64
name:
type: string
image:
type: string
format: byte
Expand Down Expand Up @@ -69919,6 +69935,8 @@ definitions:
imageId:
type: string
format: uint64
name:
type: string
DecentralCardGame.cardchain.cardchain.QueryQEncountersWithImageResponse:
type: object
properties:
Expand Down Expand Up @@ -69949,6 +69967,8 @@ definitions:
imageId:
type: string
format: uint64
name:
type: string
image:
type: string
format: byte
Expand Down
8 changes: 7 additions & 1 deletion x/cardchain/keeper/msg_server_encounter_close.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,20 @@ func (k msgServer) EncounterClose(goCtx context.Context, msg *types.MsgEncounter
index := slices.Index(user.OpenEncounters, msg.EncounterId)

if index == -1 {
return nil, sdkerrors.Wrapf(errors.ErrUnauthorized, "encounter %d isnt open for user", msg.EncounterId)
return nil, sdkerrors.Wrapf(errors.ErrUnauthorized, "encounter %d isn't open for user", msg.EncounterId)
}

user.OpenEncounters = append(user.OpenEncounters[:index], user.OpenEncounters[index+1:]...)

if msg.Won {
user.WonEncounters = append(user.WonEncounters, msg.EncounterId)
// TODO: Treasury reward here

encounter := k.Encounters.Get(ctx, msg.EncounterId)
if !encounter.Proven {
encounter.Proven = true
k.Encounters.Set(ctx, msg.EncounterId, encounter)
}
}

return &types.MsgEncounterCloseResponse{}, nil
Expand Down

0 comments on commit 552eb88

Please sign in to comment.