/traderous

To get this branch, use:
bzr branch http://9ix.org/bzr/traderous

« back to all changes in this revision

Viewing changes to planet.lua

  • Committer: Josh C
  • Date: 2013-06-30 14:59:35 UTC
  • Revision ID: josh@9ix.org-20130630145935-y34o51cg3lsom5bg
"safe" zone on planets - no new enemies will track you if you're there.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Planet = Tile:extend {
2
2
   image = 'data/planet1.png',
 
3
   potentialGoods = {
 
4
      {name = 'Bobble-Headed Dolls',
 
5
       low = 50, med = 100, high = 150,
 
6
       chance = 0.5},
 
7
      {name = 'Alliance Foodstuffs',
 
8
       low = 100, med = 250, high = 400,
 
9
       chance = 0.8},
 
10
      {name = 'Antique Weapons',
 
11
       low = 5000, med = 6000, high = 8000,
 
12
       chance = 0.1}
 
13
   },
3
14
   goods = {},
4
15
   onNew = function (self)
5
16
              self.indicator = Tile:new{ image = 'data/planet1ind.png' }
17
28
                 end
18
29
              end
19
30
 
 
31
              while #self.goods == 0 do
 
32
                 for _, good in ipairs(self.potentialGoods) do
 
33
                    if math.random() < good.chance then
 
34
                       local tier = math.random(4) -- betw 1 and 4
 
35
                       if tier == 1 then
 
36
                          table.insert(self.goods, {good.name, good.low})
 
37
                       elseif tier ==2 then
 
38
                          table.insert(self.goods, {good.name, good.high})
 
39
                       else
 
40
                          -- double chance for med (3 or 4)
 
41
                          table.insert(self.goods, {good.name, good.med})
 
42
                       end
 
43
                    end
 
44
                 end
 
45
              end
 
46
 
20
47
              self.label = Text:new {
21
48
                 text = self.name,
22
49
                 x = self.x,