<commit_before>--------------------------------------------------------------------------------
-- tower.lua - Defines a tower which has the ability to fire upon enemies
--------------------------------------------------------------------------------

local class = flower.class
require "source/gridNeighbors"
require "source/utilities/vector"
require "source/sound/sound"

local soundManager = SoundManager {
    volume = 0.1,
}
local fireSound = soundManager:addSound("assets/sounds/laser2.wav")

Tower = class()

function Tower.serialize_pos(pos)
    return table.concat(pos, " ")
end

---
-- The constructor.
function Tower:init(towerType, pos)
    self.type = towerType
    self.pos = pos
    self.targets = {}
    self.level = 1
    self.killCount = 0
    self.fire_tick = self.type.speed
    if self.pos then
        self:calculate_targets()
    end
end

function Tower:getDescription()
    return self.type.name ..
        "\nCost:" .. self.type.cost ..
        "\nRange:" .. self.type.range ..
        "  Damage:".. self.type.damage ..
        ((self.killCount > 0 and (" \nKilled: " .. self.killCount)) or "")
end

function Tower:fire(enemies)
    if self.fire_tick == self.type.speed then
        for i=#enemies,1, -1 do<commit_msg>Added displaying of attack speed for towers (#38).<commit_after>--------------------------------------------------------------------------------
-- tower.lua - Defines a tower which has the ability to fire upon enemies
--------------------------------------------------------------------------------

local class = flower.class
require "source/gridNeighbors"
require "source/utilities/vector"
require "source/sound/sound"

local soundManager = SoundManager {
    volume = 0.1,
}
local fireSound = soundManager:addSound("assets/sounds/laser2.wav")

Tower = class()

function Tower.serialize_pos(pos)
    return table.concat(pos, " ")
end

---
-- The constructor.
function Tower:init(towerType, pos)
    self.type = towerType
    self.pos = pos
    self.targets = {}
    self.level = 1
    self.killCount = 0
    self.fire_tick = self.type.speed
    if self.pos then
        self:calculate_targets()
    end
end

function Tower:getDescription()
    return self.type.name ..
        "\nCost:" .. self.type.cost .. "  Damage: " .. self.type.damage ..
        "\nRange:" .. self.type.range .. "  Attack Rate: " .. self.type.speed ..
        ((self.killCount > 0 and (" \nKills: " .. self.killCount)) or "")
end

function Tower:fire(enemies)
    if self.fire_tick == self.type.speed then
        for i=#enemies,1, -1 do
{'fraction_non_alphanumeric': 0.2421752738654147, 'fraction_numerical': 0.007042253521126761, 'mean_word_length': 1.8068057080131723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3586471', 'n_tokens_mistral': 753, 'n_tokens_neox': 726, 'n_words': 181}