Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/junon-common/protocol/enum.proto
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ enum BuildingType {
UnbreakableWall = 270;
Dynamite = 271;
MiasmaGate = 272;
Scythe = 273;
}

enum TerrainType {
Expand Down
Binary file added packages/junon-io/client/assets/images/scythe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions packages/junon-io/client/src/entities/equipments/hand/scythe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const MeleeEquipment = require("./melee_equipment")
const Protocol = require('../../../../common/util/protocol')
const Constants = require("../../../../common/constants.json")

class Pitchfork extends MeleeEquipment {

getType() {
return Protocol.definition().BuildingType.Pitchfork
}

getConstantsTable() {
return "Equipments.Pitchfork"
}

use(player, targetEntity) {
if (targetEntity && targetEntity.isCrop && targetEntity.isCrop()) {
// interact with the crop (harvest/destroy fully grown)
if (targetEntity.isFullyGrown && targetEntity.isFullyGrown()) {
targetEntity.interact(player)

// destroy left and right fully grown crops
this._destroyNeighbors(player, targetEntity)
}
} else {
// fallback to normal melee use
super.use(player, targetEntity)
}
}

_destroyNeighbors(player, target) {
const x = target.getX()
const y = target.getY()
const room = target.room

if (!room) return

const neighbors = [
room.getTile(x - 1, y),
room.getTile(x + 1, y)
]

neighbors.forEach(tile => {
if (!tile) return

const crop = tile.getBuilding && tile.getBuilding()

if (crop && crop.isCrop && crop.isCrop() && crop.isFullyGrown && crop.isFullyGrown()) {
if (crop.interact) {
crop.interact(player)
} else if (crop.breakBuilding) {
crop.breakBuilding(player)
}
}
})
}
}

module.exports = Pitchfork
1 change: 1 addition & 0 deletions packages/junon-io/client/src/entities/equipments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Equipments.BloodBottle = require("./hand/blood_bottle")
Equipments.WaterBottle = require("./hand/water_bottle")
Equipments.Disinfectant = require("./hand/disinfectant")
Equipments.Lighter = require("./hand/lighter")
Equipments.Scythe = require("./hand/scythe")
Equipments.Wrench = require("./hand/wrench")
Equipments.SurvivalTool = require("./hand/survival_tool")
Equipments.Drill = require("./hand/drill")
Expand Down
19 changes: 19 additions & 0 deletions packages/junon-io/common/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -3912,6 +3912,25 @@
"cost": {
"gold": 1000
},
"Scythe": {
"parent": "Equipments.MeleeEquipment",
"isWeapon": true,
"cost": {
"gold": 350
},
"categories": {"melee_damage": true},
"isAnimatable": true,
"stats": {
"damage": 12,
"range": 55,
"meleeRange": 55
},
"requirements": {
"IronBar": 30,
"Wood":10
},
"description": "Farms crops to left and right. Can be seconded as a weapon"
},
"categories": {"melee_damage": true},
"isAnimatable": true,
"stats": {
Expand Down
1 change: 1 addition & 0 deletions packages/junon-io/server/entities/equipments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Equipments.FireExtinguisher = require("./hand/fire_extinguisher")
Equipments.Syringe = require("./hand/syringe")
Equipments.FlameThrower = require("./hand/flame_thrower")
Equipments.Mop = require("./hand/mop")
Equipments.Scythe = require("./hand/scythe")
Equipments.Bottle = require("./hand/bottle")
Equipments.BloodBottle = require("./hand/blood_bottle")
Equipments.WaterBottle = require("./hand/water_bottle")
Expand Down
58 changes: 58 additions & 0 deletions packages/junon-io/server/entities/equipments/scythe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const MeleeEquipment = require("./melee_equipment")
const Protocol = require('../../../../common/util/protocol')
const Constants = require("../../../../common/constants.json")

class Scythe extends MeleeEquipment {

getType() {
return Protocol.definition().BuildingType.Scythe
}

getConstantsTable() {
return "Equipments.Scythe"
}

use(player, targetEntity) {
if (targetEntity && targetEntity.isCrop && targetEntity.isCrop()) {
// interact with the crop (harvest/destroy fully grown)
if (targetEntity.isFullyGrown && targetEntity.isFullyGrown()) {
targetEntity.interact(player)

// destroy left and right fully grown crops
this._destroyNeighbors(player, targetEntity)
}
} else {
// fallback to normal melee use
super.use(player, targetEntity)
}
}

_destroyNeighbors(player, target) {
const x = target.getX()
const y = target.getY()
const room = target.room

if (!room) return

const neighbors = [
room.getTile(x - 1, y),
room.getTile(x + 1, y)
]

neighbors.forEach(tile => {
if (!tile) return

const crop = tile.getBuilding && tile.getBuilding()

if (crop && crop.isCrop && crop.isCrop() && crop.isFullyGrown && crop.isFullyGrown()) {
if (crop.interact) {
crop.interact(player)
} else if (crop.breakBuilding) {
crop.breakBuilding(player)
}
}
})
}
}

module.exports = Scythe