-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplanets.lua
More file actions
83 lines (57 loc) · 1.64 KB
/
Copy pathplanets.lua
File metadata and controls
83 lines (57 loc) · 1.64 KB
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
M = {}
M.__index = M
function M.new(parentType)
local self = setmetatable({
parentType = parentType,
imgSeed = love.math.random(1, 25),
nameSeed = love.math.random(1, 40),
descSeed = love.math.random(1, 24),
typeSeed = love.math.random(1, 100),
interactionSeed = love.math.random(1, 10),
actionTaken = false,
actionResult = nil
}, M)
self.src = planetRImage(self.imgSeed)
self.name = planetRName(self.nameSeed)
self.pType = planetRType(self.typeSeed, self.parentType)
self.desc = planetRDesc(self.descSeed)
self.inter = planetRInteraction(self.interactionSeed, self.pType)
return self
end
function planetRImage(seed)
local posY = math.floor(seed / 5)
if seed == 5 then posY = 0 elseif seed == 40 then posY = 4 end
local posX = seed % 5
p = gr.newQuad(64*posX, 64*posY, 64, 64, planetSheet:getDimensions())
return p
end
function planetRName(seed)
return planetNames[seed]
end
function planetRDesc(seed)
return planetDescriptions[seed]
end
function planetRType(seed, t)
if seed <= 50 then return t
elseif seed <= 60 then return "fuel"
elseif seed <= 85 then return "ore"
else return "research" end
end
function planetRInteraction(seed, pType)
if pType == "fuel" then
return fuelActions[seed]
elseif pType == "ore" then
return moneyActions[seed]
elseif pType == "research" then
return researchActions[seed]
else
if seed % 2 == 0 then
return moneyActions[seed]
elseif seed % 3 == 0 then
return fuelActions[seed]
else
return researchActions[seed]
end
end
end
return M