Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
74b3af09
Commit
74b3af09
authored
14 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
simplified module template, added some shit
parent
16ea3e95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
exec/ircbots/poker/poker_commands.js
+27
-34
27 additions, 34 deletions
exec/ircbots/poker/poker_commands.js
exec/ircbots/poker/poker_functions.js
+30
-7
30 additions, 7 deletions
exec/ircbots/poker/poker_functions.js
exec/ircbots/poker/pokerbot.js
+10
-7
10 additions, 7 deletions
exec/ircbots/poker/pokerbot.js
with
67 additions
and
48 deletions
exec/ircbots/poker/poker_commands.js
+
27
−
34
View file @
74b3af09
this
.
Bot_Commands
[
"
DEAL
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
this
.
Bot_Commands
[
"
DEAL
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
Bot_Commands
[
"
DEAL
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
Bot_Commands
[
"
DEAL
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
cmd
.
shift
();
if
(
!
poker_games
[
target
])
{
srv
.
o
(
target
,
onick
+
"
just started a new poker hand. To get
"
...
...
@@ -9,7 +9,10 @@ this.Bot_Commands["DEAL"].command = function (target,onick,ouh,srv,lvl,cmd) {
poker_games
[
target
]
=
new
Poker_Game
();
poker_games
[
target
].
users
[
onick
.
toUpperCase
()]
=
new
Poker_Player
();
}
else
if
(
poker_games
[
target
].
users
[
onick
.
toUpperCase
()])
{
srv
.
o
(
target
,
onick
+
"
, you're already in the hand. Relax, don't do it.
"
);
if
(
poker_games
[
target
].
users
[
onick
.
toUpperCase
()].
active
)
srv
.
o
(
target
,
onick
+
"
, you're already in the hand. Relax, don't do it.
"
);
else
srv
.
o
(
target
,
onick
+
"
, you already folded. Wait until the next hand.
"
);
}
else
{
poker_games
[
target
].
users
[
onick
.
toUpperCase
()]
=
new
Poker_Player
();
srv
.
o
(
target
,
onick
+
"
has been dealt in for this hand.
"
);
...
...
@@ -17,8 +20,8 @@ this.Bot_Commands["DEAL"].command = function (target,onick,ouh,srv,lvl,cmd) {
return
;
}
this
.
Bot_Commands
[
"
GO
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
this
.
Bot_Commands
[
"
GO
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
Bot_Commands
[
"
GO
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
Bot_Commands
[
"
GO
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
cmd
.
shift
();
if
(
!
poker_games
[
target
])
{
srv
.
o
(
target
,
"
No poker game to 'GO' with. Type '
"
+
get_cmd_prefix
()
+
"
DEAL' to
"
...
...
@@ -39,37 +42,27 @@ this.Bot_Commands["GO"].command = function (target,onick,ouh,srv,lvl,cmd) {
return
;
}
this
.
Bot_Commands
[
"
FOLD
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
this
.
Bot_Commands
[
"
FOLD
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
if
(
!
poker_games
[
target
])
{
srv
.
o
(
target
,
onick
+
"
, there is no game in progress.
"
);
return
;
}
else
if
(
!
poker_games
[
target
].
users
[
onick
.
toUpperCase
()])
{
srv
.
o
(
target
,
onick
+
"
, you aren't playing this game.
"
);
return
;
}
else
if
(
poker_games
[
target
].
round
<
0
)
{
srv
.
o
(
target
,
onick
+
"
, the game hasn't started yet.
"
);
return
;
}
Bot_Commands
[
"
FOLD
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
Bot_Commands
[
"
FOLD
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
if
(
!
poker_verify_game_status
(
target
,
srv
,
onick
))
return
;
delete
poker_games
[
target
].
users
[
onick
.
toUpperCase
()];
poker_games
[
target
].
bet
+=
poker_games
[
target
].
users
[
onick
.
toUpperCase
()].
bet
;
poker_games
[
target
].
users
[
onick
.
toUpperCase
()].
active
=
false
;
srv
.
o
(
target
,
onick
+
"
folded their hand.
"
);
poker_next_turn
(
target
,
srv
);
return
;
}
this
.
Bot_Commands
[
"
CHECK
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
this
.
Bot_Commands
[
"
CHECK
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
Bot_Commands
[
"
CHECK
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
Bot_Commands
[
"
CHECK
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
if
(
!
poker_verify_game_status
(
target
,
srv
,
onick
))
return
;
srv
.
o
(
target
,
onick
+
"
checks.
"
);
poker_next_turn
(
target
,
srv
);
return
;
}
this
.
Bot_Commands
[
"
BET
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
this
.
Bot_Commands
[
"
BET
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
Bot_Commands
[
"
BET
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
Bot_Commands
[
"
BET
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
if
(
!
poker_verify_game_status
(
target
,
srv
,
onick
))
return
;
if
(
!
cmd
[
1
])
{
srv
.
writeout
(
"
NOTICE
"
+
p
+
"
:
"
+
"
You must specify an amount to bet!
"
);
...
...
@@ -95,8 +88,8 @@ this.Bot_Commands["BET"].command = function (target,onick,ouh,srv,lvl,cmd) {
return
;
}
this
.
Bot_Commands
[
"
CALL
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
this
.
Bot_Commands
[
"
CALL
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
Bot_Commands
[
"
CALL
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
Bot_Commands
[
"
CALL
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
if
(
!
poker_verify_game_status
(
target
,
srv
,
onick
))
return
;
var
poker
=
poker_games
[
target
];
if
(
poker
.
current_bet
>
poker
.
users
[
onick
.
toUpperCase
()].
money
)
{
...
...
@@ -112,8 +105,8 @@ this.Bot_Commands["CALL"].command = function (target,onick,ouh,srv,lvl,cmd) {
return
;
}
this
.
Bot_Commands
[
"
RAISE
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
this
.
Bot_Commands
[
"
RAISE
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
Bot_Commands
[
"
RAISE
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
Bot_Commands
[
"
RAISE
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
if
(
!
poker_verify_game_status
(
target
,
srv
,
onick
))
return
;
if
(
!
cmd
[
1
])
{
srv
.
writeout
(
"
NOTICE
"
+
onick
+
"
:
"
+
"
You must specify an amount to raise!
"
);
...
...
@@ -126,7 +119,7 @@ this.Bot_Commands["RAISE"].command = function (target,onick,ouh,srv,lvl,cmd) {
srv
.
writeout
(
"
NOTICE
"
+
onick
+
"
:
"
+
"
Balance: $
"
+
poker
.
users
[
onick
.
toUpperCase
()].
money
);
return
;
}
srv
.
o
(
target
,
onick
+
"
raises the bet to $
"
+
poker
.
current_bet
+
bet
);
srv
.
o
(
target
,
onick
+
"
raises the bet to $
"
+
Number
(
poker
.
current_bet
)
+
bet
);
poker
.
users
[
onick
.
toUpperCase
()].
money
-=
bet
;
poker
.
users
[
onick
.
toUpperCase
()].
bet
+=
bet
;
poker
.
current_bet
+=
bet
;
...
...
@@ -135,13 +128,13 @@ this.Bot_Commands["RAISE"].command = function (target,onick,ouh,srv,lvl,cmd) {
return
;
}
this
.
Bot_Commands
[
"
STATUS
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
this
.
Bot_Commands
[
"
STATUS
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
Bot_Commands
[
"
STATUS
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
Bot_Commands
[
"
STATUS
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
return
;
}
this
.
Bot_Commands
[
"
LIST
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
this
.
Bot_Commands
[
"
LIST
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
Bot_Commands
[
"
LIST
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
Bot_Commands
[
"
LIST
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
if
(
!
poker_games
[
target
])
{
srv
.
o
(
target
,
"
There is no active game.
"
);
return
;
...
...
@@ -154,8 +147,8 @@ this.Bot_Commands["LIST"].command = function (target,onick,ouh,srv,lvl,cmd) {
return
;
}
this
.
Bot_Commands
[
"
SHOW
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
this
.
Bot_Commands
[
"
SHOW
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
Bot_Commands
[
"
SHOW
"
]
=
new
Bot_Command
(
0
,
false
,
false
);
Bot_Commands
[
"
SHOW
"
].
command
=
function
(
target
,
onick
,
ouh
,
srv
,
lvl
,
cmd
)
{
if
(
!
poker_games
[
target
])
{
srv
.
o
(
target
,
"
There is no active game.
"
);
return
;
...
...
This diff is collapsed.
Click to expand it.
exec/ircbots/poker/poker_functions.js
+
30
−
7
View file @
74b3af09
/* IRC Bot Module - Server Commands
You would place all of your module functions in this file. */
this
.
Server_command
=
function
(
srv
,
cmdline
,
onick
,
ouh
)
function
Server_command
(
srv
,
cmdline
,
onick
,
ouh
)
{
var
cmd
=
IRC_parsecommand
(
cmdline
);
switch
(
cmd
[
0
])
{
...
...
@@ -53,6 +53,7 @@ function poker_next_turn(target,srv) {
poker
.
turn
++
;
if
(
poker
.
turn
==
poker
.
users_map
.
length
)
poker
.
turn
=
0
;
if
(
poker
.
deal_next
)
{
poker_load_pot
(
target
,
srv
);
switch
(
++
poker
.
round
)
{
...
...
@@ -65,13 +66,33 @@ function poker_next_turn(target,srv) {
case
3
:
poker_deal_river
(
target
,
srv
);
break
;
default
:
poker_compare_hands
(
target
,
srv
);
break
;
}
poker
.
deal_next
=
false
;
}
else
{
var
turn_user
=
poker
.
users
[
poker
.
users_map
[
poker
.
turn
]];
if
(
poker
.
current_bet
==
turn_user
.
bet
)
poker
.
deal_next
=
true
;
}
poker_prompt_player
(
target
,
srv
);
if
(
poker
.
round
<
4
)
poker_prompt_player
(
target
,
srv
);
}
function
poker_compare_hands
(
target
,
srv
)
{
var
poker
=
poker_games
[
target
];
var
winning_hand
=-
1
;
var
winning_player
=-
1
;
for
(
var
p
in
poker
.
users
)
{
var
player
=
poker
.
users
[
p
];
var
hand
=
poker
.
community_cards
.
concat
(
player
.
cards
)
var
rank
=
Rank
(
hand
);
if
(
rank
>
winning_hand
)
{
winning_hand
=
rank
;
winning_player
=
p
;
}
}
srv
.
o
(
target
,
winning_player
+
"
won this hand with
"
+
RANKS
[
winning_hand
]);
}
function
poker_deal_flop
(
target
,
srv
)
{
...
...
@@ -100,7 +121,7 @@ function poker_deal_turn(target,srv) {
function
poker_deal_river
(
target
,
srv
)
{
var
poker_game
=
poker_games
[
target
];
poker_game
.
community_cards
[
4
]
=
poker_game
.
deck
.
deal
();
srv
.
o
(
target
,
"
The River:
"
+
srv
.
o
(
target
,
"
The River:
"
+
poker_show_card
(
poker_game
.
community_cards
[
0
])
+
poker_show_card
(
poker_game
.
community_cards
[
1
])
+
poker_show_card
(
poker_game
.
community_cards
[
2
])
...
...
@@ -126,9 +147,7 @@ function poker_load_pot(target,srv) {
function
poker_prompt_player
(
target
,
srv
)
{
var
poker
=
poker_games
[
target
];
var
turn
=
poker
.
users_map
[
poker
.
turn
];
srv
.
o
(
turn
,
"
It is your turn. You may CHECK, CALL, BET, RAISE or FOLD.
"
+
"
Minimum bet: $
"
+
poker
.
current_bet
,
"
NOTICE
"
);
srv
.
o
(
turn
,
"
It is your turn. Minimum bet: $
"
+
poker
.
current_bet
,
"
NOTICE
"
);
}
function
poker_verify_game_status
(
target
,
srv
,
onick
)
{
...
...
@@ -137,8 +156,12 @@ function poker_verify_game_status(target,srv,onick) {
srv
.
o
(
target
,
"
No poker game in progress. Type '
"
+
get_cmd_prefix
()
+
"
DEAL' to start a new one.
"
)
return
false
;
}
if
(
poker
.
round
<
0
)
{
srv
.
o
(
target
,
onick
+
"
, the game hasn't started yet.
"
);
return
false
;
}
if
(
!
poker
.
users
[
onick
.
toUpperCase
()])
{
if
(
!
poker
.
users
[
onick
.
toUpperCase
()]
||
!
poker
.
users
[
onick
.
toUpperCase
()].
active
)
{
srv
.
o
(
onick
,
"
You're not even in the hand!
"
);
return
false
;
}
...
...
This diff is collapsed.
Click to expand it.
exec/ircbots/poker/pokerbot.js
+
10
−
7
View file @
74b3af09
var
poker_dir
=
this
.
dir
;
var
poker_scores
=
[];
var
notice_interval
=
10
;
//seconds
var
activity_timeout
=
120
;
var
poker_games
=
[];
poker_dir
=
this
.
dir
;
poker_scores
=
[];
notice_interval
=
10
;
//seconds
activity_timeout
=
120
;
poker_games
=
[];
this
.
save
=
function
()
// Game functions
function
save
()
{
var
s_file
=
new
File
(
poker_dir
+
"
scores.ini
"
);
if
(
!
s_file
.
open
(
file_exists
(
s_file
.
name
)?
"
r+
"
:
"
w+
"
))
return
false
;
...
...
@@ -14,7 +15,7 @@ this.save=function()
}
s_file
.
close
();
}
this
.
main
=
function
(
srv
,
target
)
function
main
(
srv
,
target
)
{
var
poker
=
poker_games
[
target
];
if
(
!
poker
||
poker
.
paused
)
return
;
...
...
@@ -37,6 +38,7 @@ this.main=function(srv,target)
}
}
// Game objects
function
Poker_Game
()
{
this
.
last_update
=
0
;
...
...
@@ -68,6 +70,7 @@ function Poker_Player()
this
.
cards
=
[];
this
.
money
=
100
;
this
.
bet
=
0
;
this
.
active
=
true
;
}
load_scores
();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment