diff --git a/vacuum_gambit.p8 b/vacuum_gambit.p8 index 2f5effa..5291039 100644 --- a/vacuum_gambit.p8 +++ b/vacuum_gambit.p8 @@ -1522,6 +1522,89 @@ end -- see obsidian vault for -- full docs. +flotilla = mknew{ + use_var = 0x0001, + opt_odds = split"0.5,0.5,0.5,0.5", + init=function(this) + this.ship_bases={ + [0]=mknew(ship_mook.new{ship_t=0}), + [1]=mknew(ship_mook.new{ship_t=1}), + [4]=mknew(ship_defender.new{ship_t=4}), + [5]=mknew(ship_defender.new{ship_t=5}), + [8]=mknew(ship_turret.new{ship_t=8}), + [9]=mknew(ship_turret.new{ship_t=9}), + [12]=mknew(ship_skirmisher.new{ship_t=12}), + [13]=mknew(ship_skirmisher.new{ship_t=13}), + } + end, +} + +function flotilla:load(ulc_cx, ulc_cy, lvl) + local rows,cy,uv,counts={},ulc_cy,self.use_var+0xc840,{ + [0]=0, + [1]=0, + [4]=0, + [5]=0, + [8]=0, + [9]=0, + [12]=0, + [13]=0, + } + repeat + local row,cx,opt,f = {},ulc_cx,{},0 + for i,v in ipairs(self.opt_odds) do + opt[i*4-4]=rnd()>ship_t&0x1)&(f&0x10>>4) + add(row, self.ship_bases[ship_t]:new{column=cx-ulc_cx}) + end + end + until mode==1 + -- mode 1: end of line control mark + -- bits 0x18: what size flotilla is this row used for? + if (f&0x18)>>3 <= lvl then + -- keep the row; count it + for s in all(row) do + counts[s.ship_t] += 1 + end + add(rows, row) + end + -- control mark bit 0x04: end of flotilla + until f&0x04 == 1 + self.rows=rows + self:statisfy(counts) +end + +function flotilla:statisfy(counts) + -- TODO: now that we know how + -- many ships of each kind + -- exist, build ships to match + -- difficulty target + -- + -- no difficulty model is yet + -- implemented, though, so + -- just use base ships only + -- for this prototype +end + +function flotilla:update() + -- TODO: assign new want_x, want_y to everyone who isn't dead +end + -->8 -- level and event system