forked from Aze-Cards/aze-server
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat: Adding proc fold, its endpoint and its unit test #13
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b4d82d4
add rough check method
rishotics c014864
comments over contract procedures
nlok5923 168545a
change logic
rishotics 6024f1e
add new logic
rishotics 308d70a
fixes in play check procedure
nlok5923 fd4fee3
Merge branch 'main' into rg/add-play-check
rishotics 3365537
add brainstorm
rishotics 72a235c
merge
rishotics 4ae955b
add play fold
rishotics 8347ec3
Merge branch 'main' into rg/add-play-check
Created-for-a-purpose d551424
feat: add proc fold
Created-for-a-purpose 93f7e3d
fix: remove redundant code
Created-for-a-purpose 824c535
fix: adding some changes
Created-for-a-purpose 4d75c70
fix: add constants in notescript
Created-for-a-purpose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
use.miden::account | ||
use.miden::note | ||
use.miden::contracts::wallets::basic->wallet | ||
|
||
const.NO_OF_PLAYERS_INDEX=57 | ||
const.CURRENT_TURN_INDEX=60 | ||
const.PLAYER_STATS_SLOTS=13 | ||
|
||
proc.play_fold | ||
push.CURRENT_TURN_INDEX exec.account::get_item | ||
# => [0, 0, 0, current_turn_index] | ||
|
||
drop drop drop | ||
# => [current_turn_index] | ||
|
||
push.9 | ||
# 9, current_turn_index | ||
add | ||
# => [current_turn_index + 9] | ||
dup #for getting the get item | ||
dup #for updating the turn | ||
# => [current_turn_index + 9, current_turn_index + 9, current_turn_index + 9] | ||
|
||
# getting the is_fold of player | ||
exec.account::get_item | ||
drop drop drop | ||
# => [is_fold, current_turn_index + 9, current_turn_index + 9] | ||
|
||
# making sure that is_fold is zero currently | ||
assertz | ||
# => [current_turn_index + 9, current_turn_index + 9] | ||
push.1 | ||
# => [1, current_turn_index + 9, current_turn_index + 9] | ||
|
||
swap padw drop movup.3 | ||
# => [current_turn_index + 9, 0, 0, 0, 1, current_turn_index + 9] | ||
exec.account::set_item | ||
dropw drop drop drop | ||
# => [current_turn_index + 9] | ||
|
||
# adding 4 will give the slot of next player | ||
push.4 add | ||
# => [next_turn_index] | ||
|
||
# find last player's index | ||
push.NO_OF_PLAYERS_INDEX exec.account::get_item | ||
drop drop drop | ||
# => [no_of_players, next_turn_index] | ||
|
||
# Calculate last_player_index = 52 + 13 * no_of_players + 0 | ||
push.13 mul | ||
push.52 add | ||
# => [last_player_index, next_turn_index] | ||
|
||
mem_store.0 | ||
# => [next_turn_index] | ||
|
||
push.1 | ||
# => [1, next_turn_index] | ||
|
||
while.true | ||
|
||
dup push.9 add | ||
# => [next_turn_index + 9, next_turn_index] | ||
exec.account::get_item | ||
drop drop drop | ||
# => [is_fold, next_turn_index] | ||
|
||
if.true | ||
# if player has folded | ||
dup mem_load.0 lt | ||
# => [0/1, next_turn_index] | ||
|
||
if.true | ||
push.PLAYER_STATS_SLOTS add | ||
push.1 | ||
# => [1, next_turn_index + 13] | ||
else | ||
push.0 | ||
end | ||
else | ||
# checking is fold | ||
# => [next_turn_index] | ||
|
||
padw drop | ||
# => [0, 0, 0, next_turn_index] | ||
|
||
push.CURRENT_TURN_INDEX # slot of current turn | ||
# => [CURRENT_TURN_INDEX, 0, 0, 0, next_turn_index] | ||
|
||
exec.account::set_item | ||
dropw dropw | ||
# => [...] | ||
push.0 | ||
end | ||
end | ||
dropw | ||
# => [...] | ||
end | ||
|
||
begin | ||
dropw | ||
|
||
call.play_fold | ||
# => [...] | ||
|
||
dropw | ||
exec.note::get_assets drop mem_loadw | ||
# => [ASSET, ...] | ||
|
||
# load the asset and add it to the account | ||
call.wallet::receive_asset | ||
# => [...] | ||
|
||
dropw | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since 52 and 13 would always remain fixed so can you create constants for storing these values. Or use them if you have already created one.