Pontoon (21s/Blackjack) - Game Script

Which hub software is the best? Where can I find script XXX? Discuss it here...(no, this is not for advertising your hub...)

Moderator: Moderators

Locked
FLiXD
Posts: 8
Joined: 2003-02-16 07:01

Pontoon (21s/Blackjack) - Game Script

Post by FLiXD » 2003-03-02 15:36

For anyone who fancies a game of cards.
As far as I know, only works for NMHub.
Needs to access txt files (incl in zip), so read the instructions...
Direct download here... enjoy...

ButterflySoul
Posts: 210
Joined: 2003-01-23 17:24
Location: Nevada
Contact:

Post by ButterflySoul » 2003-03-08 19:10

Very nice script =) I have it running in my hub. Here's a few comments :

1) Bug
If someone has a 5 card trick, the next player is asked if he/she wants to "stick/twist/buy", then the player who had the trick is asked as well.

The "stuck" flag is handled properly though, and the script considers it is the next player's turn. This is simply a messaging issue.

2) Improvements

a) When you play it in the main chat instead of via PMs, the p-off filtering doesn't work in the original script. So I modified the SendMC2A Function from :

Code: Select all

If InPM=True Then
 Nicks=oPlayer.Keys
  For i = oPlayer.Count-1 To 0 Step -1
    ColUsers.ItemByName(Cstr(Nicks(i))).PrivateMessage Cstr(sBotName), (sMessage)
  Next
Else
  colUsers.SendChatToAll Cstr(sBotName), (sMessage)
End If


To :

Code: Select all

   Nicks=oPlayer.Keys
   If InPM Then
      For i = oPlayer.Count-1 To 0 Step -1
         ColUsers.ItemByName(Cstr(Nicks(i))).PrivateMessage Cstr(sBotName), (sMessage)
      Next
   Else
      For i = oPlayer.Count-1 To 0 Step -1
         ColUsers.ItemByName(Cstr(Nicks(i))).SendChatMessage Cstr(sBotName), (sMessage)
      Next
   End If


b) I didn't get too deep into the code yet, but an "automatic-topup" would definitely be great, when someone runs out of money.
Currently, you have to ask a hub OP to give you some cash in order to continue. In the long run, this might be anoying for the OPs if they're around, or for the players if no OP is around =)
(I guess you made it OP-only to prevent abuses, but if an automated top up happens only when the player is down to less than 10£, I don't see any way to abuse it)

c) Part of the success of the Trivia Bots is due to the high score table feature =)
You already keep everyone's "score" in a savings.txt file, so reading the file, and sending the top 10 scores (if above the topup amount) on request; and/or the top player to everyone in the main chat after each game could be a nice feature too.
[CoZ] Children of Zeus
-----
Shadows DC Hub - VBS and JS scripting at their best

ButterflySoul
Posts: 210
Joined: 2003-01-23 17:24
Location: Nevada
Contact:

Post by ButterflySoul » 2003-03-09 03:55

In my original edit, I applied to main chat games what the original script was doing for PM games. However, for some reason, PM games are sent to current players, and not to everyone who entered "p-on".

The problem is that when a player goes bust, they won't see the end of the game (since they're not an active player anymore) neither the question from the bot asking for a new game. Also, non-player people won't see anything of the game, no matter wether they typed p-on or p-off, which makes these 2 commands of limited use =)

Here is another version of the SendMC2A Function. This one will send all the game's info to everyone who typed "p-on" to see the games, and will filter everything for people who are under the default "p-off" status (even when the game is played in main chat) :

Code: Select all

Function SendMC2A(sMessage)
   Nicks=oUShow.Keys
   If InPM Then
      For i = 0 To oUShow.Count-1
         If oUShow(Nicks(i))="On" And ColUsers.Online(cstr(Nicks(i))) Then ColUsers.ItemByName(cstr(Nicks(i))).PrivateMessage Cstr(sBotName), (sMessage)
      Next
   Else
      For i = 0 to oUShow.Count-1
         If oUShow(Nicks(i))="On" And ColUsers.Online(cstr(Nicks(i))) Then ColUsers.ItemByName(cstr(Nicks(i))).SendChatMessage Cstr(sBotName), (sMessage)
      Next
   End If
End Function


The oUShow dictionary keeps track of everyone and their flag (on/off), and that's why I added a check to see if the user is online before sending a PM (sending PMs to offline users results in an error =).
Because of the way this dictionary works, it can end up getting real big, so it would probably be more gentle on the hub to remove offline users from the dictionary every now and then, and instead of checking if someone's value is "off", to simply check if they exist in the dictionary. However, this seems to be a design decision from FLiXD (having the script remember people's flag status when they log back on), so I didn't touch it =)
[CoZ] Children of Zeus
-----
Shadows DC Hub - VBS and JS scripting at their best

FLiXD
Posts: 8
Joined: 2003-02-16 07:01

Post by FLiXD » 2003-03-09 19:27

Yes, you are quite right, thanks for taking the time to code fixes. I spent a week on the script and by the end was quite sick of looking at it, so took a break after v106 (also built new anagram game, Ragaman - available from the bottom of download page on my site). I will get back on it soon to correct as many of the bugs as I can. Auto topup & leading player are also good ideas, will implement them when I have the time.
Glad you like the game, and can be bothered taking the time to comment... keep well
cheers, FLiXD

FLiXD
Posts: 8
Joined: 2003-02-16 07:01

Post by FLiXD » 2003-03-10 09:29

Hmmm. I have fixed most of those things in new version, but I'm stuck on 1 thing, maybe you could help me out here. Getting rankings... at the moment, in the anagram game, I use this to get rankings - but it's the one part of that script that I'm not happy with

Code: Select all

Sub GetRank()
Dim CntDn, Sc, Names, Place
  If Not oScores.Count=0 Then
   CntDn=10000: Names=oScores.Keys: Sc=oScores.Items: oRank.RemoveAll: Place=1
     Do Until CntDn=0
       CntDn=CntDn-1
       For i=0 to oScores.Count-1
       Sc(i)=Cdbl(Sc(i))       
         If Sc(i)=CntDn Then
          oRank.Add Cstr(Names(i)), Place
          Place=Place+1
         End If
       Next
     Loop
  End If
End Sub 

The two obvious disadvantages to this are:
1) CPU usage/lag caused while the script is looping through 10000*usercount
2) The fact that anyone over 10000 will not be ranked

Is there a function in VBScript that can check people's scores and rank them automatically? Any suggestions appreciated....

papapuffalot
Posts: 2
Joined: 2003-03-13 16:32

Post by papapuffalot » 2003-03-13 17:08

can you post a link to download this file agin please the first link is broken or something

ButterflySoul
Posts: 210
Joined: 2003-01-23 17:24
Location: Nevada
Contact:

Post by ButterflySoul » 2003-03-13 18:19

Actually, the link to version 1.06 doesn't work anymore because the version 1.07 is out, and that link probably won't work anymore in case 1.08 comes out =)

In case you run into that problem at a later time, try the download page for FLiXD's scripts =)
[CoZ] Children of Zeus
-----
Shadows DC Hub - VBS and JS scripting at their best

Locked