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
cee437c3
Commit
cee437c3
authored
14 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
more sorting stuff
parent
dcb28804
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/load/cardlib.js
+10
-73
10 additions, 73 deletions
exec/load/cardlib.js
with
10 additions
and
73 deletions
exec/load/cardlib.js
+
10
−
73
View file @
cee437c3
...
...
@@ -118,9 +118,8 @@ function Hunt_Straight(cards,depth) {
/* This function accepts any number of cards in as a true array */
function
Rank
(
cards
)
{
var
hand
=
new
Object
();
hand
.
group
=
new
Object
();
hand
.
group
[
0
]
=
0
;
/* Rank - no value */
hand
.
rank
=
hand
.
group
[
0
];
hand
.
group
=
new
Array
();
hand
.
rank
=
0
;
hand
.
str
=
""
;
/* First, count up the cards. */
...
...
@@ -227,80 +226,18 @@ function Rank(cards) {
if
(
hand
.
rank
!=
ST
)
hand
.
str
=
RANKS
[
hand
.
rank
];
/* Consolidate "count" array and reverse.
Only consolidate cards where count=1 */
var
consolidated
=
new
Array
;
/* Push contents of "count" array into
rank.group array using the count as
the array index. unshift() will leave
the cards sorted from high to low. */
for
(
c
in
count
)
{
if
(
count
[
c
]
==
1
)
consolidated
.
push
(
c
);
if
(
!
hand
.
group
[
count
[
c
]])
hand
.
group
[
count
[
c
]]
=
new
Array
();
hand
.
group
[
count
[
c
]].
unshift
(
c
);
}
hand
.
high
=
consolidated
.
reverse
();
consolidated
=
consolidated
.
sort
(
sortNumber
);
switch
(
hand
.
rank
)
{
case
HC
:
case
FL
:
/* Yes, FL really gets treated like HC. */
hand
.
group
[
1
]
=
consolidated
.
pop
();
hand
.
group
[
2
]
=
consolidated
.
pop
();
hand
.
group
[
3
]
=
consolidated
.
pop
();
hand
.
group
[
4
]
=
consolidated
.
pop
();
hand
.
group
[
5
]
=
consolidated
.
pop
();
break
;
case
PR
:
hand
.
group
[
1
]
=
hunt_count
(
count
,
2
);
hand
.
group
[
2
]
=
consolidated
.
pop
();
hand
.
group
[
3
]
=
consolidated
.
pop
();
hand
.
group
[
4
]
=
consolidated
.
pop
();
break
;
case
TP
:
var
first_pair
=
hunt_count
(
count
,
2
);
delete
count
[
first_pair
];
var
second_pair
=
hunt_count
(
count
,
2
);
if
(
first_pair
>
second_pair
)
{
hand
.
group
[
1
]
=
first_pair
;
hand
.
group
[
2
]
=
second_pair
;
}
else
{
hand
.
group
[
1
]
=
second_pair
;
hand
.
group
[
2
]
=
first_pair
;
}
hand
.
group
[
3
]
=
consolidated
.
pop
();
break
;
case
TK
:
hand
.
group
[
1
]
=
hunt_count
(
count
,
3
);
hand
.
group
[
2
]
=
consolidated
.
pop
();
break
;
case
ST
:
case
SF
:
hand
.
group
[
1
]
=
consolidated
.
pop
();
break
;
case
FH
:
hand
.
group
[
1
]
=
hunt_count
(
count
,
3
);
hand
.
group
[
2
]
=
hunt_count
(
count
,
2
);
hand
.
group
[
3
]
=
consolidated
.
pop
();
break
;
case
FK
:
hand
.
group
[
1
]
=
hunt_count
(
count
,
4
);
hand
.
group
[
2
]
=
consolidated
.
pop
();
break
;
case
RF
:
default
:
break
;
}
return
hand
;
}
function
hunt_count
(
cards
,
count
)
{
for
(
c
in
cards
)
{
if
(
cards
[
c
]
==
count
)
return
c
;
}
}
function
sortNumber
(
a
,
b
)
{
return
a
-
b
;
}
function
Sort
(
cards
)
{
/* Sort the cards from top (highest) to bottom (lowest) */
var
sorted
=
new
Array
();
...
...
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