Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
misterbalrog
Apprentice


Joined: 26 Oct 2004
Posts: 108

PostPosted: Mon Jan 03, 2005 2:38 pm   

Doing a Poker game...
 
Yes.. I know someone else is doing lots of game-scripts for zMUD atm, but I felt I wanted to do it aswell...

So I'm trying to do No Limit Texas Hold 'Em...

But I got stuck at one section where I'm calling for a function called "RemPlayer"..

Code:
#if (%1) {
  #delitem Players %1
  #echo @Players
  #noop
  #echo give %eval( @%1) coin %1
  #unvar %1
  #unvar %eval( %1+"Cards")
  #if (%numitems( @Players) == 2 AND @EndGame != 1) {
    #echo say Only one player remaining! Ending Game.
    #var EndGame 1
    @RemPlayer(%item(@Players,1))
    }
  }
#if (@EndGame) {
  #echo Clearing Enviroment variables
  #unvar DrawnCards
  #unvar TotalRounds
  #unvar GameRound
  #unvar Players
  #unvar Ante
  #unvar Smallblind
  #unvar Bigblind
  #unvar ButtonOffset
  #unvar TempCard
  #unvar tempsucc
  #unvar EndGame
  }


Here's the trigger that calls for the function.

Code:
#if (@Players) {
  #add TotalRounds 1
  #if (@GameRound == %NULL) {
    #var Ante 500
    #var GameRound 1
    } {#add GameRound 1}
  #if (@GameRound == 4) {
    #add Ante 250
    #var GameRound 1
    }
  #echo Game Round @TotalRounds : Small Blind Size: @Ante, Big Blind Size: %eval( @Ante*2)
  #add ButtonOffset 1
  #if (@ButtonOffset > %numitems( @Players)) {#var ButtonOffset 1}
  #var Smallblind {%eval( @ButtonOffset+1)}
  #if (@Smallblind > %numitems( @Players)) {#var Smallblind 1}
  #var Bigblind {%eval( @ButtonOffset+2)}
  #if (@Bigblind > %numitems( @Players)) {#var Bigblind {%eval( @Bigblind-%numitems( @Players))}}
  #echo say Small blind goes to %item( @Players, @Smallblind)
  #echo say Big blind goes to %item( @Players, @Bigblind)
  #if (%eval( %eval( @%item( @Players, @Smallblind)) - @Ante) < 0) {
    #echo Player %item( @Players, @Smallblind) cannot afford to pay the blind! Player removed!

    #exec @RemPlayer( %item( @Players, @Smallblind) )

    } {#var %item( @Players, @Smallblind) %eval( %eval( @%item( @Players, @Smallblind))-@Ante)}
  #if (%eval( %eval( @%item( @Players, @Bigblind)) - @Ante) < 0) {
    #echo Player %item( @Players, @Bigblind) cannot afford to pay the blind! Player removed!

    #exec @RemPlayer( %item( @Players, @Bigblind) )

    } {#var %item( @Players, @Bigblind) %eval( %eval( @%item( @Players, @Bigblind)) -(@Ante*2))}
  #echo Scoring for Round @TotalRounds
  #Forall @Players {#echo %i - %eval( @%i)}
  }


Some explanations:

When a player enters the game, it will create a variable in the player's name with the amount of cash he/she has. For instance the player Balrog enters with 10000 gold coins, then @Balrog contains 10000.
He/She is also added to the stringlist; @Players="Peldahr|Vijilante|Balrog"

Once a new Game Round starts, the script will echo the needed string to issue this trigger. To advance to the next round and to possibly increase the blinds and remove them from the players. This section works perfectly. However, if a player cannot afford the blind he/she will be automatically removed from the game. This is where the problem crops up.

The function RemPlayer is called with #exec which seems to cause that all variable-alterations in the function will not be made until the exec has completed. This causes a loop. I've made an example where a player named "Hamaz" enters with 10k, Balrog wiht 50k and Peldahr 100k.

Hamaz encounters that he cannot pay the blind as early in the game as round 12 (by simply changing rounds continually).

This is the result:
Code:

Scoring for Round 11
Hamaz - 750
Balrog - 42000
Peldahr - 89500
Blinds & Such
Game Round 12 : Small Blind Size: 1250, Big Blind Size: 2500
say Small blind goes to Hamaz
say Big blind goes to Balrog
Player Hamaz cannot afford to pay the blind! Player removed!
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
Variable Hamaz removed.
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Hamaz|Balrog|Peldahr
give 750 coin Hamaz
say Only one player remaining! Ending Game.
Peldahr
give 89500 coin Peldahr
Variable Peldahr removed.
Clearing Enviroment variables
Variable TotalRounds removed.
Variable GameRound removed.
Variable Players removed.
Variable Ante removed.
Variable Smallblind removed.
Variable Bigblind removed.
Variable ButtonOffset removed.
Variable EndGame removed.
Scoring for Round


So my question is, is there another way of calling a function and get it to manipulate the variables without waiting for the function to finish before doing so? Or do I have to make it into a trigger which triggers off an echo like the whole Blinds stuff? I'm not entirely sure that would work either.
Reply with quote
misterbalrog
Apprentice


Joined: 26 Oct 2004
Posts: 108

PostPosted: Mon Jan 03, 2005 3:06 pm   
 
It seems as if using a trigger will solve the problem, however I am still curious if there is a way to call a function properly giving the same effect...
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Mon Jan 03, 2005 3:51 pm   
 
There is always another way, since I am working on the same project for my GAMES script I know what your looking for.

I used an alias, sometimes I use it with an IF statement.

Hope that helps a bit, I not giving you the answer only because I have it in a script I am writing and will be released doon on the finished scripts forum :)
_________________
megamog75 Smile
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere
Reply with quote
icedsun
Novice


Joined: 20 Jan 2006
Posts: 45
Location: Minnesota

PostPosted: Tue Jan 24, 2006 3:34 pm   Hold 'em Rules
 
Umm, not really related to the script not working - but in Texas Hold 'Em, a player isn't removed simply for failing to be able to cover the blind (or any other bet for that matter). "Chip and a chair"... If a player only has 1 chip, and the blind is 1000000, the player would just post their 1 chip but the blind would still be 1000000 for everybody else. Of course that player could only win 1 coin multiplied by the number of other players who called at least 1 coin into the pot. But, yeah, just because you can't cover the bet doesn't mean you're out. You're only out when you have no chips left after you've lost the hand.
_________________
"Build a man a fire and he's warm for a night. Light a man on fire and he's warm for the rest of his life." --My Mom
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net