/* * Copyright (c) 2015 Shervin Asgari * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package no.asgari.civilization.server.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonTypeName; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import no.asgari.civilization.server.SheetName; @Getter @Setter @JsonTypeName("artillery") @JsonIgnoreProperties(ignoreUnknown = true) @NoArgsConstructor @EqualsAndHashCode(exclude = {"ownerId", "hidden", "used", "itemNumber"}, callSuper = false) public class Artillery extends Unit implements Image { private int level = 0; private String ownerId; private boolean hidden = true; private boolean used; private boolean killed; private int attack; private int health; private boolean isInBattle; private String image; private SheetName sheetName; private int itemNumber; public Artillery(int attack, int health) { this.attack = attack; this.health = health; } @Override public SheetName getSheetName() { return sheetName = SheetName.ARTILLERY; } @Override public String revealPublic() { return getType(); } @Override public String revealAll() { return toString(); } @Override public String toString() { switch (level) { case LEVEL_1: return "Archer " + attack + "." + health; case LEVEL_2: return "Cannon " + (attack + LEVEL_1) + "." + (health + LEVEL_1); case LEVEL_3: return "Catapult " + (attack + LEVEL_2) + "." + (health + LEVEL_2); case LEVEL_4: return "Mobile Artillery " + (attack + LEVEL_3) + "." + (health + LEVEL_3); default: return "Artillery " + attack + "." + health; } } @Override public int compareTo(Spreadsheet o) { return getSheetName().compareTo(o.getSheetName()); } @Override public String getImage() { image = getType() + attack + "." + health + PNG; return image.replaceAll(" ", ""); } }