File: flf_common.lua

package info (click to toggle)
naev 0.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 386,084 kB
  • sloc: ansic: 93,149; xml: 87,292; python: 2,347; sh: 904; makefile: 654; lisp: 162; awk: 4
file content (84 lines) | stat: -rw-r--r-- 2,401 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
--[[

   FLF mission common functions.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

--]]


-- Get a random system with FLF presence.
function flf_getSystem ()
   local choices = {}
   for i, j in ipairs( system.getAll() ) do
      local p = j:presences()
      if p["FLF"] then
         choices[#choices + 1] = j:nameRaw()
      end
   end
   return system.get(choices[rnd.rnd(1, #choices)])
end


-- Get a system generally good for an FLF mission.
-- These are systems which have both FLF and Dvaered presence.
function flf_getTargetSystem ()
   local choices = {}
   for i, j in ipairs( system.getAll() ) do
      local p = j:presences()
      if p["FLF"] and p["Dvaered"] then
         choices[#choices + 1] = j:nameRaw()
      end
   end
   return system.get(choices[rnd.rnd(1, #choices)])
end


-- Get a system with both FLF and Empire presence.
function flf_getEmpireSystem ()
   local choices = {}
   for i, j in ipairs( system.getAll() ) do
      local p = j:presences()
      if p["FLF"] and p["Empire"] then
         choices[#choices + 1] = j:nameRaw()
      end
   end
   return system.get(choices[rnd.rnd(1, #choices)])
end


-- Get a system with both FLF and Pirate presence.
function flf_getPirateSystem ()
   local choices = {}
   for i, j in ipairs( system.getAll() ) do
      local p = j:presences()
      if p[ "FLF" ] and p[ "Pirate" ] then
         choices[#choices + 1] = j:nameRaw()
      end
   end
   return system.get(choices[rnd.rnd(1, #choices)])
end


-- Change the reputation cap for the FLF.
function flf_setReputation( newcap )
   var.push( "_fcap_flf", math.max(newcap, var.peek("_fcap_flf") or 5) )
end


-- Add an entry to the FLF campaign log.
function flf_addLog( text )
   shiplog.createLog( "flf", _("FLF"), _("Frontier") )
   shiplog.appendLog( "flf", text )
end