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
c213f622
Commit
c213f622
authored
13 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
fix dicerolling bug, fix forfeit()
parent
23eb8ddc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
xtrn/dicewarz/dice.js
+9
-10
9 additions, 10 deletions
xtrn/dicewarz/dice.js
xtrn/dicewarz/diceroll.js
+15
-23
15 additions, 23 deletions
xtrn/dicewarz/diceroll.js
with
24 additions
and
33 deletions
xtrn/dicewarz/dice.js
+
9
−
10
View file @
c213f622
...
...
@@ -57,7 +57,7 @@ var scores= [];
var
messages
=
[];
//MESSAGES QUEUED FOR DISPLAY UPON RELOADING MAIN MENU
var
games
=
new
GameStatusInfo
();
var
settings
=
new
GameSettings
();
var
dice
=
loadDice
();
var
game
dice
=
loadDice
();
var
oldpass
=
console
.
ctrlkey_passthru
;
js
.
on_exit
(
"
file_remove(userFileName);
"
);
...
...
@@ -902,14 +902,13 @@ function battle(attackFrom,attackTo,gameNumber)
clearArea
(
16
,
menuColumn
,
8
);
showSelected
(
attackFrom
,
"
\
1n
\
1r
\
1h
"
);
showSelected
(
attackTo
,
"
\
1n
\
1r
\
1h
"
);
var
totals
=
rollDice
(
attackFrom
.
dice
,
attackTo
.
dice
);
var
totals
=
rollDice
(
attackFrom
.
dice
,
attackTo
.
dice
,
gamedice
);
var
defender
=
attackTo
.
player
;
var
attacker
=
attackFrom
.
player
;
var
defending
=
attackTo
.
location
;
var
attacking
=
attackFrom
.
location
;
if
(
totals
[
0
]
>
totals
[
1
])
{
if
(
totals
[
0
]
>
totals
[
1
])
{
g
.
players
[
defender
].
removeTerritory
(
defending
);
//REMOVE TILE FROM DEFENDER'S LIST
g
.
players
[
attacker
].
territories
.
push
(
defending
);
//ADD TILE TO ATTACKER'S LIST
g
.
players
[
defender
].
totalDice
-=
(
attackTo
.
dice
);
...
...
@@ -917,9 +916,7 @@ function battle(attackFrom,attackTo,gameNumber)
g
.
grid
[
defending
].
assign
(
attacker
,
g
.
players
[
attacker
]);
g
.
grid
[
defending
].
dice
=
(
attackFrom
.
dice
-
1
);
if
(
g
.
players
[
defender
].
territories
.
length
==
0
)
{
g
.
eliminatePlayer
(
defender
,
attacker
);
}
}
g
.
grid
[
attacking
].
dice
=
1
;
attackFrom
.
show
();
...
...
@@ -948,14 +945,15 @@ function forfeit(gameNumber,playerNumber)
var
p
=
g
.
players
[
playerNumber
];
if
(
p
.
user
>
0
)
{
Log
(
"
forfeiting
"
+
system
.
username
(
g
.
players
[
playerNumber
].
user
)
+
"
in game
"
+
gm
.
gameNumber
);
Log
(
"
forfeiting
"
+
system
.
username
(
g
.
players
[
playerNumber
].
user
)
+
"
in game
"
+
gameNumber
);
scores
[
p
.
user
].
losses
+=
1
;
scores
[
p
.
user
].
score
+=
settings
.
forfeitPoints
;
}
else
{
Log
(
"
forfeiting
"
+
g
.
players
[
playerNumber
].
AI
.
name
+
"
in game
"
+
gameNumber
);
}
if
(
g
.
singlePlayer
)
if
(
g
.
singlePlayer
&&
p
.
user
>
0
)
file_remove
(
g
.
fileName
);
else
{
var
activePlayers
=
g
.
countActivePlayers
();
...
...
@@ -1119,10 +1117,11 @@ function takeTurnAI(gameNumber,playerNumber)
/* if we are down to two players */
if
(
g
.
countActivePlayers
().
length
==
2
)
{
var
perc
=
computerPlayer
.
countTerritory
()
/
g
.
mapSize
;
/* if this ai occupies less than a quarter of the map, forfeit the game */
if
((
computerPlayer
.
countTerritory
()
/
g
.
mapSize
)
<
(
0.25
))
{
Log
(
"
computer player forfeiting game
"
+
gameNumber
);
if
(
perc
<
0.25
)
{
forfeit
(
gameNumber
,
playerNumber
);
return
false
;
}
}
...
...
This diff is collapsed.
Click to expand it.
xtrn/dicewarz/diceroll.js
+
15
−
23
View file @
c213f622
//#########################DICE ROLLING FUNCTIONS############################
function
rollDice
(
a
,
b
)
function
rollDice
(
a
,
b
,
dice
)
{
//MAIN DICE ROLLING FUNCTION
var
totals
=
[
0
,
0
];
var
x
=
menuColumn
;
var
y
=
16
;
var
x
=
menuColumn
;
var
y
=
16
;
bc
=
console
.
ansi
(
BG_RED
);
fc
=
console
.
ansi
(
LIGHTGRAY
);
fancyRoll
(
a
,
x
,
y
,
fc
,
bc
);
fancyRoll
(
a
,
x
,
y
,
fc
,
bc
,
dice
);
xx
=
x
;
yy
=
y
;
for
(
aa
=
0
;
aa
<
a
;
aa
++
)
{
for
(
aa
=
0
;
aa
<
a
;
aa
++
)
{
rand
=
(
random
(
6
)
+
1
);
dice
[
rand
].
display
(
xx
,
yy
,
fc
,
bc
);
xx
+=
4
;
...
...
@@ -23,11 +23,10 @@ function rollDice(a,b)
bc
=
console
.
ansi
(
BG_LIGHTGRAY
);
fc
=
console
.
ansi
(
RED
);
fancyRoll
(
b
,
x
,
y
,
fc
,
bc
);
fancyRoll
(
b
,
x
,
y
,
fc
,
bc
,
dice
);
xx
=
x
;
yy
=
y
;
for
(
bb
=
0
;
bb
<
b
;
bb
++
)
{
for
(
bb
=
0
;
bb
<
b
;
bb
++
)
{
rand
=
(
random
(
6
)
+
1
);
totals
[
1
]
+=
rand
;
dice
[
rand
].
display
(
xx
,
yy
,
fc
,
bc
);
...
...
@@ -38,14 +37,12 @@ function rollDice(a,b)
printf
(
"
\
1n
\
1r
\
1hAttacker:
"
+
totals
[
0
]
+
"
\
1n Defender:
"
+
totals
[
1
]);
return
totals
;
}
function
fancyRoll
(
qty
,
x
,
y
,
fc
,
bc
)
function
fancyRoll
(
qty
,
x
,
y
,
fc
,
bc
,
dice
)
{
//"ROLLING DICE" DISPLAY
for
(
roll
=
0
;
roll
<
8
;
roll
++
)
{
for
(
roll
=
0
;
roll
<
8
;
roll
++
)
{
xx
=
x
;
yy
=
y
;
for
(
dr
=
0
;
dr
<
qty
;
dr
++
)
{
for
(
dr
=
0
;
dr
<
qty
;
dr
++
)
{
dice
[
random
(
6
)
+
1
].
display
(
xx
,
yy
,
fc
,
bc
);
xx
+=
4
;
}
...
...
@@ -60,13 +57,11 @@ function Die(number)
this
.
line3
=
"
"
;
this
.
dot
=
"
\
xFE
"
;
if
(
this
.
number
==
2
||
this
.
number
==
3
)
{
if
(
this
.
number
==
2
||
this
.
number
==
3
)
{
this
.
line1
=
this
.
dot
+
"
"
;
this
.
line3
=
"
"
+
this
.
dot
;
}
if
(
this
.
number
==
4
||
this
.
number
==
5
||
this
.
number
==
6
)
{
if
(
this
.
number
==
4
||
this
.
number
==
5
||
this
.
number
==
6
)
{
this
.
line1
=
this
.
dot
+
"
"
+
this
.
dot
;
this
.
line3
=
this
.
dot
+
"
"
+
this
.
dot
;
}
...
...
@@ -74,8 +69,7 @@ function Die(number)
this
.
line2
=
"
"
+
this
.
dot
+
"
"
;
if
(
this
.
number
==
6
)
this
.
line2
=
this
.
dot
+
"
"
+
this
.
dot
;
this
.
display
=
function
(
x
,
y
,
b
,
f
)
{
this
.
display
=
function
(
x
,
y
,
b
,
f
)
{
console
.
gotoxy
(
x
,
y
);
y
++
;
printf
(
f
+
b
+
this
.
line1
);
console
.
gotoxy
(
x
,
y
);
y
++
;
...
...
@@ -87,10 +81,8 @@ function Die(number)
}
function
loadDice
()
{
//INITIALIZE SIX SIDED DICE OBJECTS
dice_
=
[];
for
(
d
=
1
;
d
<=
6
;
d
++
)
{
var
dice_
=
[];
for
(
d
=
1
;
d
<=
6
;
d
++
)
dice_
[
d
]
=
new
Die
(
d
);
}
return
dice_
;
}
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