Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
archery
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
archery
Commits
c4b62167
Commit
c4b62167
authored
Jan 16, 2016
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start implementing how crosses are saved in database
parent
a2446176
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
archery.mwb
archery.mwb
+0
-0
util.php
util.php
+45
-0
No files found.
archery.mwb
View file @
c4b62167
No preview for this file type
util.php
View file @
c4b62167
...
...
@@ -93,6 +93,51 @@ function unpack_scores($blob) {
return
array_map
(
function
(
$c
)
{
return
unpack
(
'C'
,
$c
)[
1
];
},
str_split
(
$blob
));
}
function
pack_crosses
(
$crosses
)
{
$blob
=
''
;
$byte
=
0
;
$i
=
7
;
foreach
(
$crosses
as
$bit
)
{
$byte
|=
intval
(
$bit
)
<<
$i
;
if
(
$i
==
0
)
{
$blob
.=
chr
(
$byte
);
$byte
=
0
;
$i
=
7
;
}
else
{
$i
--
;
}
}
if
(
$i
!=
7
)
$blob
.=
pack
(
'C'
,
$byte
);
return
$blob
;
}
function
unpack_crosses
(
$bitmap
,
$limit
=
0
)
{
$crosses
=
array
();
foreach
(
$bitmap
as
$c
)
{
for
(
$i
=
7
;
$i
>=
0
;
$i
--
)
{
$crosses
[]
=
intval
(
!!
(
ord
(
$c
)
&
(
1
<<
$i
)));
if
(
count
(
$crosses
)
==
$limit
)
return
$crosses
;
}
}
return
$crosses
;
}
function
show_crosses
(
$bitmap
)
{
foreach
(
$bitmap
as
$c
)
{
for
(
$i
=
7
;
$i
>=
0
;
$i
--
)
echo
intval
(
!!
(
ord
(
$c
)
&
(
1
<<
$i
)));
echo
' '
;
}
echo
"
\n
"
;
}
//show_crosses("\x0b\xff\x00\x08");
show_crosses
(
pack_crosses
(
array
(
1
,
0
,
1
,
0
,
0
,
0
,
0
,
0
)));
exit
;
function
match_arrows
(
$row
)
{
return
sprintf
(
'%d × %d'
,
$row
->
turns
,
$row
->
arrows
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment