Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
6
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
coUserver
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Children of Ur
coUserver
Commits
77c8f94b
Commit
77c8f94b
authored
May 25, 2017
by
Craig S. Cottingham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip street if not in_game
parent
8ae00a68
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
48 deletions
+52
-48
lib/achievements/achievement_checkers.dart
lib/achievements/achievement_checkers.dart
+52
-48
No files found.
lib/achievements/achievement_checkers.dart
View file @
77c8f94b
part of
achievements
;
class
AchievementCheckers
{
static
Achievement
getCompletistIdForhub
(
String
hubId
)
{
try
{
String
hubName
=
MapData
.
hubs
[
hubId
.
toString
()][
'name'
];
hubName
=
hubName
.
toLowerCase
().
replaceAll
(
' '
,
'_'
);
return
Achievement
.
find
(
'
${hubName}
_completist'
);
}
catch
(
e
,
st
)
{
Log
.
error
(
'Failed getting completist achv id for <hubId=
$hubId
>'
,
e
,
st
);
return
new
Achievement
();
}
}
static
Achievement
getCompletistIdForhub
(
String
hubId
)
{
try
{
String
hubName
=
MapData
.
hubs
[
hubId
.
toString
()][
'name'
];
hubName
=
hubName
.
toLowerCase
().
replaceAll
(
' '
,
'_'
);
return
Achievement
.
find
(
'
${hubName}
_completist'
);
}
catch
(
e
,
st
)
{
Log
.
error
(
'Failed getting completist achv id for <hubId=
$hubId
>'
,
e
,
st
);
return
new
Achievement
();
}
}
// Checks if the addedTsid completes a hub
static
bool
hubCompletion
(
List
<
String
>
locationHistory
,
String
email
,
String
addedTsid
)
{
bool
_checkStreetsInHub
(
String
hubId
)
{
for
(
Map
<
String
,
dynamic
>
data
in
MapData
.
getStreetsInHub
(
hubId
))
{
if
(
data
[
'tsid'
]
==
null
)
{
Log
.
warning
(
'Missing TSID for
$data
'
);
continue
;
}
if
(!
locationHistory
.
contains
(
tsidL
(
data
[
'tsid'
])))
{
// Not visited
return
false
;
}
}
// Checks if the addedTsid completes a hub
static
bool
hubCompletion
(
List
<
String
>
locationHistory
,
String
email
,
String
addedTsid
)
{
bool
_checkStreetsInHub
(
String
hubId
)
{
for
(
Map
<
String
,
dynamic
>
data
in
MapData
.
getStreetsInHub
(
hubId
))
{
if
(
data
[
'tsid'
]
==
null
)
{
Log
.
warning
(
'Missing TSID for
$data
'
);
continue
;
}
if
(!(
data
[
'in_game'
]
??
true
))
{
// Not possible to visit
continue
;
}
if
(!
locationHistory
.
contains
(
tsidL
(
data
[
'tsid'
])))
{
// Not visited
return
false
;
}
}
// Visited every street in hub
return
true
;
}
// Visited every street in hub
return
true
;
}
String
addedTsidHubId
;
try
{
addedTsidHubId
=
MapData
.
getStreetByTsid
(
addedTsid
)[
'hub_id'
].
toString
();
if
(
addedTsidHubId
==
'null'
)
{
throw
new
Exception
(
'addedTsidHubId may not be null'
);
}
}
catch
(
_
)
{
Log
.
warning
(
'Cannot find hub id for
$addedTsid
'
);
return
false
;
}
String
addedTsidHubId
;
try
{
addedTsidHubId
=
MapData
.
getStreetByTsid
(
addedTsid
)[
'hub_id'
].
toString
();
if
(
addedTsidHubId
==
'null'
)
{
throw
new
Exception
(
'addedTsidHubId may not be null'
);
}
}
catch
(
_
)
{
Log
.
warning
(
'Cannot find hub id for
$addedTsid
'
);
return
false
;
}
if
(
_checkStreetsInHub
(
addedTsidHubId
))
{
try
{
AchievementCheckers
.
getCompletistIdForhub
(
addedTsidHubId
).
awardTo
(
email
);
return
true
;
}
catch
(
_
)
{
Log
.
warning
(
'Awarding completist <addedTsidHubId=
$addedTsidHubId
> to <email=
$email
> failed'
);
return
false
;
}
}
else
{
return
false
;
}
}
if
(
_checkStreetsInHub
(
addedTsidHubId
))
{
try
{
AchievementCheckers
.
getCompletistIdForhub
(
addedTsidHubId
).
awardTo
(
email
);
return
true
;
}
catch
(
_
)
{
Log
.
warning
(
'Awarding completist <addedTsidHubId=
$addedTsidHubId
> to <email=
$email
> failed'
);
return
false
;
}
}
else
{
return
false
;
}
}
}
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