2024-05-06 22:55:58 +02:00
|
|
|
package domain;
|
|
|
|
|
|
|
|
import domain.sheets.*;
|
|
|
|
|
2024-05-07 01:10:14 +02:00
|
|
|
import java.util.HashMap;
|
|
|
|
|
2024-05-06 22:55:58 +02:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-05-07 01:10:14 +02:00
|
|
|
public void writeCategory(Category categoryToWrite, boolean crossing){
|
2024-05-06 22:55:58 +02:00
|
|
|
switch (categoryToWrite.toString()){
|
2024-05-07 01:10:14 +02:00
|
|
|
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;
|
2024-05-06 22:55:58 +02:00
|
|
|
case "Sevens":
|
|
|
|
sevens = (Sevens) categoryToWrite;
|
2024-05-07 01:10:14 +02:00
|
|
|
manageArrays(crossing, sevens);
|
2024-05-06 22:55:58 +02:00
|
|
|
break;
|
|
|
|
case "Eights":
|
|
|
|
eights = (Eights) categoryToWrite;
|
2024-05-07 01:10:14 +02:00
|
|
|
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);
|
2024-05-06 22:55:58 +02:00
|
|
|
break;
|
|
|
|
case "StarWarsDay":
|
|
|
|
starWarsDay = (StarWarsDay) categoryToWrite;
|
2024-05-07 01:10:14 +02:00
|
|
|
manageArrays(crossing, starWarsDay);
|
2024-05-06 22:55:58 +02:00
|
|
|
break;
|
|
|
|
case "R2D2":
|
|
|
|
r2D2 = (R2D2) categoryToWrite;
|
2024-05-07 01:10:14 +02:00
|
|
|
manageArrays(crossing, r2D2);
|
2024-05-06 22:55:58 +02:00
|
|
|
break;
|
2024-05-07 01:10:14 +02:00
|
|
|
case "Yahtzee":
|
|
|
|
yahtzee = (Yahtzee) categoryToWrite;
|
|
|
|
manageArrays(crossing, yahtzee);
|
|
|
|
break;
|
|
|
|
case "Chance":
|
|
|
|
chance = (Chance) categoryToWrite;
|
|
|
|
manageArrays(crossing, chance);
|
2024-05-06 22:55:58 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-05-07 01:10:14 +02:00
|
|
|
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;
|
|
|
|
}
|
2024-05-06 22:55:58 +02:00
|
|
|
|
2024-05-07 01:10:14 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2024-05-06 22:55:58 +02:00
|
|
|
}
|