Skip to content

Commit

Permalink
Spy missions should considered harmful
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Aug 29, 2018
1 parent 93cacd9 commit 90d4986
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ogame.go
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,8 @@ func extractAttacks(pageHTML string) []AttackEvent {
missionTypeInt, _ := strconv.Atoi(missionTypeStr)
arrivalTimeInt, _ := strconv.Atoi(arrivalTimeStr)
missionType := MissionID(missionTypeInt)
if missionType != Attack && missionType != GroupedAttack && missionType != MissileAttack {
if missionType != Attack && missionType != GroupedAttack &&
missionType != MissileAttack && missionType != Spy {
return
}
attack := AttackEvent{}
Expand Down
6 changes: 6 additions & 0 deletions ogame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func TestExtractAttacks(t *testing.T) {
assert.Equal(t, 1, len(attacks))
}

func TestExtractAttacks_spy(t *testing.T) {
pageHTMLBytes, _ := ioutil.ReadFile("samples/event_list_spy.html")
attacks := extractAttacks(string(pageHTMLBytes))
assert.Equal(t, 1, len(attacks))
}

func TestExtractAttacks1(t *testing.T) {
pageHTMLBytes, _ := ioutil.ReadFile("samples/event_list_missile.html")
attacks := extractAttacks(string(pageHTMLBytes))
Expand Down
80 changes: 80 additions & 0 deletions samples/event_list_spy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

<div id="eventListWrap">
<div id="eventHeader">
<a class="close_details eventToggle" href="javascript:void(0);">
<img src="https://gf2.geo.gfsrv.net/cdndf/3e567d6f16d040326c7a0ea29a4f41.gif" height="16" width="16" />
</a>
<h2>Events</h2>
</div> <table id="eventContent">
<tbody>

<tr class="eventFleet" id="eventRow-13516738" data-mission-type="6"
data-return-flight="false"
data-arrival-time="1535565265"
>
<td class="countDown hostile textBeefy" id="counter-eventlist-13516738">
load... </td>
<td class="arrivalTime">18:54:25 Clock </td>

<td class="missionFleet">
<img src="https://gf3.geo.gfsrv.net/cdnb7/60a018ae3104b4c7e5af8b2bde5aee.gif"
class="tooltipHTML" title="Enemy fleet|Espionage"

/>
</td>

<td class="originFleet">
<figure class="planetIcon planet"></figure>Homeworld
</td>
<td class="coordsOrigin">
<a href="https://s152-en.ogame.gameforge.com/game/index.php?page=galaxy&galaxy=4&system=212" target="_top">
[4:212:8] </a>
</td>


<td class="detailsFleet">
<span>8</span>
</td>
<td class="icon_movement">
<span class="tooltip tooltipRight tooltipClose"
title="&lt;div class=&quot;htmlTooltip&quot;&gt;
&lt;h1&gt;Fleet details:&lt;/h1&gt;
&lt;div class=&quot;splitLine&quot;&gt;&lt;/div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;fleetinfo&quot;&gt;
&lt;tr&gt;
&lt;th colspan=&quot;2&quot;&gt;Ships:&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Light Fighter:&lt;/td&gt;
&lt;td class=&quot;value&quot;&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Espionage Probe:&lt;/td&gt;
&lt;td class=&quot;value&quot;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
" data-federation-user-id="">&nbsp;</span>
</td>
<td class="destFleet">
<figure class="planetIcon planet"></figure>Homeworld </td>

<td class="destCoords">
<a href="https://s152-en.ogame.gameforge.com/game/index.php?page=galaxy&galaxy=4&system=116" target="_top">
[4:116:12] </a>
</td>


<td class="sendProbe">
</td>
<td class="sendMail">
<a href="javascript:void(0)"
class="sendMail js_openChat tooltip"
data-playerId="107009"
title="Constable Telesto"><span class="icon icon_chat"></span></a> </td>
</tr>

</tbody>
</table> <div id="eventFooter"></div>
</div><script type="text/javascript">
var timeDelta=1535522740000-(new Date()).getTime();var LocalizationStrings={"timeunits":{"short":{"year":"y","month":"m","week":"w","day":"d","hour":"h","minute":"m","second":"s"}},"status":{"ready":"done"},"decimalPoint":".","thousandSeperator":".","unitMega":"Mn","unitKilo":"K","unitMilliard":"Bn","question":"Question","error":"Error","loading":"load...","yes":"yes","no":"No","ok":"Ok","attention":"Caution","outlawWarning":"You are about to attack a stronger player. If you do this, your attack defences will be shut down for 7 days and all players will be able to attack you without punishment. Are you sure you want to continue?","lastSlotWarningMoon":"This building will use the last available building slot. Expand your Lunar Base to receive more space. Are you sure you want to build this building?","lastSlotWarningPlanet":"This building will use the last available building slot. Expand your Terraformer or buy a Planet Field item to obtain more slots. Are you sure you want to build this building?","forcedVacationWarning":"Confirm your lobby account now and we\u2019ll gift you Dark Matter in each universe!","moreDetails":"More details","lessDetails":"Less detail","planetOrder":{"lock":"Lock arrangement","unlock":"Unlock arrangement"},"darkMatter":"Dark Matter","activateItem":{"upgradeItemQuestion":"Would you like to replace the existing item? The old bonus will be lost in the process.","upgradeItemQuestionHeader":"Replace item?"}};$(document).ready(function(){new eventboxCountdown($("#counter-eventlist-13516738"),42525,$('#eventListWrap'),"https:\/\/s152-en.ogame.gameforge.com\/game\/index.php?page=checkEvents&ajax=1",[13516738]);initEventTable();});</script>

0 comments on commit 90d4986

Please sign in to comment.