Skip to content

Commit

Permalink
eecs fixes and love for scenario wh
Browse files Browse the repository at this point in the history
  • Loading branch information
Piglit committed Sep 15, 2024
1 parent c5405b9 commit c148931
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Receives SpySat intel and prints it."""
"""Receives messages for the Fernschreiber."""
import pyrohelper
import Pyro4

Expand All @@ -12,4 +12,4 @@ def recv(self, msg):
print(msg) # TODO

rcv = Receiver()
pyrohelper.host_named_server(rcv, "spysatReceiver")
pyrohelper.host_named_server(rcv, "Fernschreiber")
36 changes: 34 additions & 2 deletions eecs/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import models.crew
import models.scenario
import outbound.stationsComms
import outbound.pyroMessage
from interfaces import storage
import json
import string

# load scenarios, that should be available in the campaign.
# use the complete filename without the folder.
Expand Down Expand Up @@ -42,6 +44,32 @@
"""
models.crew.setCrewTemplate(["20_training1"], ["Phobos M3P"], briefing)

def cypher(text, key):
result = ""
key = key.lower()
for index,char in enumerate(text):
key_index = index % len(key)
key_char = key[key_index]
key_ord = ord(key_char) - ord("a")
if char in string.ascii_lowercase:
char = ord(char) + key_ord
if char > ord("z"):
char -= 26
char = chr(char)
elif char in string.ascii_uppercase:
char = ord(char) + key_ord
if char > ord("Z"):
char -= 26
char = chr(char)
elif char in string.digits:
char = ord(char) + key_ord
while char > ord("9"):
char -= 10
char = chr(char)
result += char
return result


def unlockAtlantis(crew):
crew.unlockShip("Atlantis")
crew.unlockScenario("21_training2", settings={"Ships": ["Corvettes"]})
Expand Down Expand Up @@ -235,8 +263,12 @@ def scenario_event(scenario: models.scenario.Scenario, crew: models.crew.Crew, e
fleetcommand_name = details
storage.storeInfo(details, "fleetcommand_name")
outbound.stationsComms.subscribe_comms_log(crew.instance_name, details)
if event_topic == "fleetcommand-deleted":
elif event_topic == "fleetcommand-deleted":
outbound.stationsComms.unsubscribe_comms_log()

elif event_topic == "exuari-comms":
msg = details
chiffre = cypher(msg, "exuari")
msg = "Wir haben eine Subraum-Übertragung aufgefangen:\n\n"+chiffre
outbound.pyroMessage.send("Fernschreiber", msg)

core.subscribe("scenario_event", scenario_event)
4 changes: 2 additions & 2 deletions eecs/models/crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def _artifactCallback(self, success):
def sendReputation(self, reduce=False):
"""send reputation bonus to server, granting it the current ship"""
amount = self.getTotalReputationBonus(reduce)
log.info(f"{self.crew_name} requested {amount} reputation bonus to {self.instance_name}")
log.info(f"{self.crew_name} requested {amount} reputation bonus to {self.instance_name}")
if amount <= 0:
return
script = f"""
Expand All @@ -290,7 +290,7 @@ def _repCallback(self, reduce, success):
if "delivered" not in self.scores:
self.scores["delivered"] = {"reputation": 0}
self.scores["delivered"]["reputation"] -= amount
log.info(f"{self.crew_name} {amount} reputation has been delivered.")
log.info(f"{self.crew_name} {amount} reputation has been delivered.")


def storeCrew(self):
Expand Down
5 changes: 5 additions & 0 deletions eecs/outbound/pyroMessage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from utils import pyrohelper

def send(name, msg):
pyrohelper.connect_to_named(name).recv(msg)

17 changes: 16 additions & 1 deletion scripts-piglit/plots/wh_exuari.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,24 @@ end
function wh_exuari.onTeleport(wormhole, teleportee)
if wh_exuari.state == "ambush" and wormhole == wh_wormhole.wormhole_b and teleportee.typeName == "PlayerSpaceship" then
local value = teleportee:getResourceAmount("Artifacts")
print(string.format("Exuari behold wormhole use with %d artifacts.", value))

if value > 1 then
wh_exuari:spawnAmbush(teleportee, value)
local ship = wh_exuari.ships[#wh_exuari.ships]
local msg
if ship ~= nil and ship:isValid() then
msg = string.format("%s %s reports: death-team arrived in sector %s, intercepting %s %s in %s with %d artifacts.", ship:getTypeName(), ship:getCallSign(), ship:getSectorName(), teleportee:getTypeName(), teleportee:getCallSign(), teleportee:getSectorName(), value)
else
msg = string.format("Death-team arrived, intercepting %s %s in %s with %d artifacts.", teleportee:getTypeName(), teleportee:getCallSign(), teleportee:getSectorName(), value)
end
sendMessageToCampaignServer("exuari-comms", msg)
end
end
if teleportee == wh_fleetcommand.station then
if wormhole == wh_wormhole.wormhole_a then
wh_exuari.state = "idle"
else
wh_exuari.state = "ambush"
end
end
end
Expand Down
8 changes: 6 additions & 2 deletions scripts-piglit/plots/wh_fleetcommand.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function wh_fleetcommand.spawnFleetCommand()
fc:setResourceAmount(name, -1)
fc:setResourceCategory(name, "Dock Upgrades")
fc:setResourceDescription(name, "Allows the station to repair the hull of docked ships.")
name = "Science Probe Factory"
name = "Probe Data Receiver"
fc:setResourceAmount(name, -2)
fc:setResourceCategory(name, "Dock Upgrades")
fc:setResourceDescription(name, "Allows the station to restock docked ships with probes.")
Expand Down Expand Up @@ -129,6 +129,10 @@ function wh_fleetcommand.spawnFleetCommand()
fc.last_pos_x, fc.last_pos_y = fc:getPosition()
fc.jumped_time = 0
fc.exclude_from_health_check = true

if wh_exuari ~= nil then
wh_exuari.state = "ambush"
end
sendMessageToCampaignServer("fleetcommand-spawned", fc:getCallSign()) -- notify campaign server on where the fleet command is and what it's name is.
end

Expand All @@ -140,7 +144,7 @@ function wh_fleetcommand.upgrade(resource)
fc:setSharesEnergyWithDocked(true)
elseif resource == "Hull Repair Scaffold" then
fc:setRepairDocked(true)
elseif resource == "Science Probe Factory" then
elseif resource == "Probe Data Receiver" then
fc:setRestocksScanProbes(false)
elseif resource == "Torpedo Armory" then
fc:setRestocksMissilesDocked("playerships")
Expand Down

0 comments on commit c148931

Please sign in to comment.