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
4e5a05fd
Commit
4e5a05fd
authored
11 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
some minor patches.. now echicken can take his turns
parent
b760e11e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
xtrn/dicewarz2/dice.ini
+1
-1
1 addition, 1 deletion
xtrn/dicewarz2/dice.ini
xtrn/dicewarz2/diceobj.js
+1
-3
1 addition, 3 deletions
xtrn/dicewarz2/diceobj.js
xtrn/dicewarz2/game.js
+112
-92
112 additions, 92 deletions
xtrn/dicewarz2/game.js
xtrn/dicewarz2/service.js
+12
-1
12 additions, 1 deletion
xtrn/dicewarz2/service.js
with
126 additions
and
97 deletions
xtrn/dicewarz2/dice.ini
+
1
−
1
View file @
4e5a05fd
...
...
@@ -47,7 +47,7 @@ highlight_color= LIGHTRED
;points awarded
[point_set]
win
=
2
win
=
1
loss
=
-2
kill
=
1
forfeit
=
-1
\ No newline at end of file
This diff is collapsed.
Click to expand it.
xtrn/dicewarz2/diceobj.js
+
1
−
3
View file @
4e5a05fd
...
...
@@ -100,9 +100,7 @@ function Data()
}
this
.
saveGame
=
function
(
game
)
{
var
location
=
"
games.
"
+
game
.
gameNumber
;
client
.
lock
(
game_id
,
location
,
2
);
client
.
write
(
game_id
,
location
,
game
);
client
.
unlock
(
game_id
,
location
);
client
.
write
(
game_id
,
location
,
game
,
2
);
this
.
games
[
game
.
gameNumber
]
=
game
;
}
this
.
saveWinner
=
function
(
game
)
{
...
...
This diff is collapsed.
Click to expand it.
xtrn/dicewarz2/game.js
+
112
−
92
View file @
4e5a05fd
...
...
@@ -31,63 +31,6 @@ function loadGraphic(filename) {
f
.
open
();
return
f
;
}
function
menuPrompt
(
string
,
append
,
keepOpen
,
hotkeys
)
{
if
(
!
append
)
promptFrame
.
clear
();
if
(
!
promptFrame
.
is_open
)
promptFrame
.
open
();
promptFrame
.
putmsg
(
string
);
promptFrame
.
draw
();
var
cmd
=
""
;
while
(
!
js
.
terminated
)
{
var
k
=
console
.
getkey
(
K_NOECHO
|
K_NOCRLF
|
K_UPPER
|
K_NOSPIN
);
if
(
hotkeys
)
{
cmd
=
k
;
break
;
}
if
(
k
==
"
\r
"
)
{
break
;
}
cmd
+=
k
;
promptFrame
.
putmsg
(
k
);
promptFrame
.
cycle
();
}
if
(
!
keepOpen
)
promptFrame
.
close
();
return
cmd
;
}
function
numberPrompt
(
string
,
append
,
keepOpen
)
{
if
(
!
append
)
promptFrame
.
clear
();
if
(
!
promptFrame
.
is_open
)
promptFrame
.
open
();
promptFrame
.
putmsg
(
string
);
promptFrame
.
draw
();
var
cmd
=
[];
while
(
!
js
.
terminated
)
{
var
k
=
console
.
getkey
(
K_NOECHO
|
K_NOCRLF
|
K_NUMBER
|
K_NOSPIN
);
if
(
k
==
"
\r
"
)
{
break
;
}
else
if
(
k
==
"
\
b
"
)
{
if
(
cmd
.
length
>
0
)
{
cmd
.
pop
();
promptFrame
.
putmsg
(
k
);
promptFrame
.
cycle
();
}
}
else
{
cmd
.
push
(
k
);
promptFrame
.
putmsg
(
k
);
promptFrame
.
cycle
();
}
}
if
(
!
keepOpen
)
promptFrame
.
close
();
return
cmd
.
join
(
""
);
}
function
menuText
(
string
,
append
)
{
if
(
!
append
)
promptFrame
.
clear
();
...
...
@@ -110,10 +53,10 @@ function splash(file) {
function
submitMessage
(
f
,
msg
)
{
var
str
=
""
;
if
(
msg
.
nick
)
var
str
=
getColor
(
chat
.
setting
s
.
NICK_COLOR
)
+
msg
.
nick
.
name
+
"
\
1n:
"
+
getColor
(
chat
.
setting
s
.
TEXT_COLOR
)
+
msg
.
str
;
var
str
=
getColor
(
chat
.
color
s
.
NICK_COLOR
)
+
msg
.
nick
.
name
+
"
\
1n:
"
+
getColor
(
chat
.
color
s
.
TEXT_COLOR
)
+
msg
.
str
;
else
var
str
=
getColor
(
chat
.
setting
s
.
NOTICE_COLOR
)
+
msg
.
str
;
var
str
=
getColor
(
chat
.
color
s
.
NOTICE_COLOR
)
+
msg
.
str
;
f
.
putmsg
(
str
+
"
\r\n
"
);
}
...
...
@@ -223,6 +166,7 @@ function lobby() {
}
function
close
()
{
client
.
unsubscribe
(
game_id
,
"
games
"
);
chat
.
disconnect
();
}
function
cycle
()
{
client
.
cycle
();
...
...
@@ -256,13 +200,14 @@ function lobby() {
return
scores
;
}
function
sortGameData
(
array
)
{
var
sorted
=
new
Object
();
sorted
.
started
=
[];
sorted
.
waiting
=
[];
sorted
.
yourgames
=
[];
sorted
.
yourturn
=
[];
sorted
.
eliminated
=
[];
sorted
.
singleplayer
=
[];
var
sorted
=
{
started
:[],
waiting
:[],
yourgames
:[],
yourturn
:[],
eliminated
:[],
singleplayer
:[]
};
for
(
var
i
in
array
)
{
var
game
=
array
[
i
];
...
...
@@ -270,9 +215,12 @@ function lobby() {
if
(
game
.
single_player
)
{
sorted
.
singleplayer
.
push
(
i
);
if
(
in_game
>=
0
)
{
if
(
in_game
>=
0
)
{
sorted
.
yourgames
.
push
(
i
);
}
if
(
game
.
turn
==
in_game
)
{
sorted
.
yourturn
.
push
(
i
);
}
}
else
{
if
(
in_game
>=
0
)
{
...
...
@@ -280,16 +228,21 @@ function lobby() {
}
if
(
game
.
status
==
status
.
PLAYING
)
{
sorted
.
started
.
push
(
i
);
if
(
game
.
turn
==
in_game
)
if
(
game
.
turn
==
in_game
)
{
sorted
.
yourturn
.
push
(
i
);
else
if
(
in_game
>=
0
&&
!
game
.
players
[
in_game
].
active
)
}
else
if
(
in_game
>=
0
&&
!
game
.
players
[
in_game
].
active
)
{
sorted
.
eliminated
.
push
(
i
);
}
}
else
{
sorted
.
waiting
.
push
(
i
);
}
}
}
for
each
(
var
s
in
sorted
)
{
s
.
sort
(
function
(
a
,
b
)
{
return
a
-
b
});
}
return
sorted
;
}
function
viewRankings
()
{
...
...
@@ -378,25 +331,10 @@ function lobby() {
var
player
=
findPlayer
(
game
,
user
.
alias
);
if
(
player
>=
0
)
{
response
=
menuPrompt
(
"
Remove yourself from this game? [y/N]
"
,
false
,
false
,
true
);
if
(
response
==
'
Y
'
)
{
game
.
players
.
splice
(
player
,
1
);
data
.
saveGame
(
game
);
return
;
}
response
=
menuPrompt
(
"
Change your vote? [y/N]
"
,
false
,
false
,
true
);
if
(
response
==
'
Y
'
)
{
current_vote
=
game
.
players
[
player
].
vote
;
game
.
players
[
player
].
vote
=
(
current_vote
?
false
:
true
);
}
askRemove
(
game
);
askChange
(
game
);
}
else
{
response
=
menuPrompt
(
"
Join this game? [y/N]
"
,
false
,
false
,
true
);
if
(
response
!==
'
Y
'
)
{
infoFrame
.
close
();
return
;
}
vote
=
menuPrompt
(
"
Vote to start? [y/N]
"
,
false
,
false
,
true
);
addPlayer
(
game
,
user
.
alias
,
system
.
name
,(
vote
==
"
Y
"
?
true
:
false
));
askJoin
(
game
);
}
if
(
game
.
players
.
length
>=
settings
.
min_players
)
{
...
...
@@ -412,7 +350,33 @@ function lobby() {
return
;
}
}
data
.
saveGame
(
game
);
}
function
askRemove
(
game
)
{
var
response
=
menuPrompt
(
"
Remove yourself from this game? [y/N]
"
,
false
,
false
,
true
);
if
(
response
==
'
Y
'
)
{
game
.
players
.
splice
(
player
,
1
);
return
;
}
}
function
askChange
(
game
)
{
var
response
=
menuPrompt
(
"
Change your vote? [y/N]
"
,
false
,
false
,
true
);
if
(
response
==
'
Y
'
)
{
var
vote
=
game
.
players
[
player
].
vote
;
game
.
players
[
player
].
vote
=
(
!
vote
);
}
}
function
askJoin
(
game
)
{
var
response
=
menuPrompt
(
"
Join this game? [y/N]
"
,
false
,
false
,
true
);
if
(
response
!==
'
Y
'
)
{
infoFrame
.
close
();
return
;
}
var
vote
=
menuPrompt
(
"
Vote to start? [y/N]
"
,
false
,
false
,
true
);
addPlayer
(
game
,
user
.
alias
,
system
.
name
,(
vote
==
"
Y
"
?
true
:
false
));
}
function
canView
(
gameNumber
)
{
//todo
return
true
;
}
function
gameList
()
{
listFrame
.
clear
();
...
...
@@ -440,7 +404,10 @@ function lobby() {
return
true
;
}
else
{
infoFrame
.
open
();
client
.
lock
(
game_id
,
"
games.
"
+
num
,
2
);
viewGameInfo
(
data
.
games
[
num
]);
client
.
write
(
game_id
,
"
games.
"
+
num
,
data
.
games
[
num
]);
client
.
unlock
(
game_id
,
"
games.
"
+
num
);
infoFrame
.
close
();
}
break
;
...
...
@@ -461,8 +428,6 @@ function lobby() {
var
map
=
generateMap
(
game
);
dispersePlayers
(
game
,
map
);
data
.
saveGame
(
game
);
data
.
saveMap
(
map
);
}
function
createNewGame
()
{
...
...
@@ -543,7 +508,62 @@ function lobby() {
}
return
false
;
}
function
menuPrompt
(
string
,
append
,
keepOpen
,
hotkeys
)
{
if
(
!
append
)
promptFrame
.
clear
();
if
(
!
promptFrame
.
is_open
)
promptFrame
.
open
();
promptFrame
.
putmsg
(
string
);
promptFrame
.
draw
();
var
cmd
=
""
;
while
(
!
js
.
terminated
)
{
var
k
=
console
.
getkey
(
K_NOECHO
|
K_NOCRLF
|
K_UPPER
|
K_NOSPIN
);
if
(
hotkeys
)
{
cmd
=
k
;
break
;
}
if
(
k
==
"
\r
"
)
{
break
;
}
cmd
+=
k
;
promptFrame
.
putmsg
(
k
);
cycle
();
}
if
(
!
keepOpen
)
promptFrame
.
close
();
return
cmd
;
}
function
numberPrompt
(
string
,
append
,
keepOpen
)
{
if
(
!
append
)
promptFrame
.
clear
();
if
(
!
promptFrame
.
is_open
)
promptFrame
.
open
();
promptFrame
.
putmsg
(
string
);
promptFrame
.
draw
();
var
cmd
=
[];
while
(
!
js
.
terminated
)
{
var
k
=
console
.
getkey
(
K_NOECHO
|
K_NOCRLF
|
K_NUMBER
|
K_NOSPIN
);
if
(
k
==
"
\r
"
)
{
break
;
}
else
if
(
k
==
"
\
b
"
)
{
if
(
cmd
.
length
>
0
)
{
cmd
.
pop
();
promptFrame
.
putmsg
(
k
);
}
}
else
{
cmd
.
push
(
k
);
promptFrame
.
putmsg
(
k
);
}
cycle
();
}
if
(
!
keepOpen
)
promptFrame
.
close
();
return
cmd
.
join
(
""
);
}
open
();
main
();
close
();
...
...
This diff is collapsed.
Click to expand it.
xtrn/dicewarz2/service.js
+
12
−
1
View file @
4e5a05fd
...
...
@@ -48,7 +48,17 @@ function loadSettings(filename) {
/* check initial status of all games (may have activity after crash or reboot) */
function
updateGames
()
{
for
each
(
var
g
in
data
.
games
)
{
updateStatus
(
g
.
gameNumber
);
try
{
updateStatus
(
g
.
gameNumber
);
}
catch
(
e
)
{
log
(
LOG_ERROR
,
"
error updating game
"
);
var
gstring
=
"
games:
"
;
for
(
var
g
in
data
.
games
)
{
gstring
+=
g
+
"
"
;
}
log
(
LOG_ERROR
,
gstring
);
}
}
}
...
...
@@ -111,6 +121,7 @@ function updateStatus(gameNumber) {
return
false
;
if
(
game
.
status
==
status
.
PLAYING
)
{
log
(
LOG_WARNING
,
"
updating turn info for game:
"
+
game
.
gameNumber
);
updateTurn
(
game
);
}
else
if
(
game
.
status
==
status
.
NEW
)
{
...
...
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