Kniffel/domain/StarwarsSheet.java

193 lines
6.0 KiB
Java

package domain;
import domain.sheets.*;
import java.util.HashMap;
public class StarwarsSheet extends Sheet{
//? Additional upper half
Sevens sevens;
Eights eights;
//? Additional lower half
StarWarsDay starWarsDay;
R2D2 r2D2;
public StarwarsSheet(){
super();
this.sevens = new Sevens();
super.unusedRows.add(this.sevens.toString());
this.eights = new Eights();
super.unusedRows.add(this.eights.toString());
this.starWarsDay = new StarWarsDay();
super.unusedRows.add(this.starWarsDay.toString());
this.r2D2 = new R2D2();
super.unusedRows.add(this.r2D2.toString());
}
public void writeCategory(Category categoryToWrite, boolean crossing){
switch (categoryToWrite.toString()){
case "Aces":
aces = (Aces) categoryToWrite;
manageArrays(crossing, aces);
break;
case "Twos":
twos = (Twos) categoryToWrite;
manageArrays(crossing, twos);
break;
case "Threes":
threes = (Threes) categoryToWrite;
manageArrays(crossing, threes);
break;
case "Fours":
fours = (Fours) categoryToWrite;
manageArrays(crossing, fours);
break;
case "Fives":
fives = (Fives) categoryToWrite;
manageArrays(crossing, fives);
break;
case "Sixes":
sixes = (Sixes) categoryToWrite;
manageArrays(crossing, sixes);
break;
case "Sevens":
sevens = (Sevens) categoryToWrite;
manageArrays(crossing, sevens);
break;
case "Eights":
eights = (Eights) categoryToWrite;
manageArrays(crossing, eights);
break;
case "ThreeOfKind":
threeOfKind = (ThreeOfKind) categoryToWrite;
manageArrays(crossing, threeOfKind);
break;
case "FourOfKind":
fourOfKind = (FourOfKind) categoryToWrite;
manageArrays(crossing, fourOfKind);
break;
case "FullHouse":
fullHouse = (FullHouse) categoryToWrite;
manageArrays(crossing, fullHouse);
break;
case "SmallStraight":
smallStraight = (SmallStraight) categoryToWrite;
manageArrays(crossing, smallStraight);
break;
case "LargeStraight":
largeStraight = (LargeStraight) categoryToWrite;
manageArrays(crossing, largeStraight);
break;
case "StarWarsDay":
starWarsDay = (StarWarsDay) categoryToWrite;
manageArrays(crossing, starWarsDay);
break;
case "R2D2":
r2D2 = (R2D2) categoryToWrite;
manageArrays(crossing, r2D2);
break;
case "Yahtzee":
yahtzee = (Yahtzee) categoryToWrite;
manageArrays(crossing, yahtzee);
break;
case "Chance":
chance = (Chance) categoryToWrite;
manageArrays(crossing, chance);
break;
}
}
public int calcUpperHalf(){
int upperSum = 0;
upperSum += aces.getValue();
upperSum += twos.getValue();
upperSum += threes.getValue();
upperSum += fours.getValue();
upperSum += fives.getValue();
upperSum += sixes.getValue();
upperSum += sevens.getValue();
upperSum += eights.getValue();
return upperSum;
}
public int calcLowerHalf(){
int lowerSum = 0;
lowerSum += threeOfKind.getValue();
lowerSum += fourOfKind.getValue();
lowerSum += fullHouse.getValue();
lowerSum += smallStraight.getValue();
lowerSum += largeStraight.getValue();
lowerSum += yahtzee.getValue();
lowerSum += starWarsDay.getValue();
lowerSum += r2D2.getValue();
lowerSum += chance.getValue();
return lowerSum;
}
public int calcUpperBonus(int upperSum){
if (upperSum >= 108){
upperSum += 35;
}
return upperSum;
}
public HashMap<String, Category> getAllCategories(){
HashMap<String, Category> allCategories = new HashMap<>();
allCategories.put("Aces", aces);
allCategories.put("Twos", twos);
allCategories.put("Threes", threes);
allCategories.put("Fours", fours);
allCategories.put("Fives", fives);
allCategories.put("Sixes", sixes);
allCategories.put("Sevens", sevens);
allCategories.put("Eights", eights);
allCategories.put("ThreeOfKind", threeOfKind);
allCategories.put("FourOfKind", fourOfKind);
allCategories.put("FullHouse", fullHouse);
allCategories.put("SmallStraight", smallStraight);
allCategories.put("LargeStraight", largeStraight);
allCategories.put("StarWarsDay", starWarsDay);
allCategories.put("R2D2", r2D2);
allCategories.put("Yahtzee", yahtzee);
allCategories.put("Chance", chance);
return allCategories;
}
//? :/
public void writeStarwarsCategory(Category categoryToWrite, boolean crossing){
switch (categoryToWrite.toString()){
case "Sevens":
sevens = (Sevens) categoryToWrite;
break;
case "Eights":
eights = (Eights) categoryToWrite;
break;
case "StarWarsDay":
starWarsDay = (StarWarsDay) categoryToWrite;
break;
case "R2D2":
r2D2 = (R2D2) categoryToWrite;
break;
default:
super.writeCategory(categoryToWrite, crossing);
break;
}
}
}