FIx: Fixed Coverage Screenshots And htmlRepot.
This commit is contained in:
@@ -0,0 +1,424 @@
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html id="htmlId">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Coverage Report > Board</title>
|
||||
<style type="text/css">
|
||||
@import "../../css/coverage.css";
|
||||
@import "../../css/idea.min.css";
|
||||
</style>
|
||||
<script type="text/javascript" src="../../js/highlight.min.js"></script>
|
||||
<script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="content">
|
||||
<div class="breadCrumbs">
|
||||
Current scope: <a href="../../index.html">all classes</a>
|
||||
<span class="separator">|</span>
|
||||
<a href="../index.html">it.polimi.ingsw.gc14.Model.GamePackage</a>
|
||||
</div>
|
||||
|
||||
<h1>Coverage Summary for Class: Board (it.polimi.ingsw.gc14.Model.GamePackage)</h1>
|
||||
|
||||
<table class="coverageStats">
|
||||
<tr>
|
||||
<th class="name">Class</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Class, %
|
||||
</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Method, %
|
||||
</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Branch, %
|
||||
</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Line, %
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name">Board</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(1/1)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(16/16)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
96.7%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(29/30)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(82/82)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<pre>
|
||||
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Model.GamePackage;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.ShamanicRitual;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.Sustenance;
|
||||
import it.polimi.ingsw.gc14.Model.DecksCreator;
|
||||
import it.polimi.ingsw.gc14.Model.Slot;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Board manages all the elements during the game such as decks, upper and lower rows, totems, tiles...
|
||||
*/
|
||||
public class Board implements Serializable {
|
||||
/**
|
||||
* slotList contains the ordered list of slots (tiles). The slots changes based on the number of players.
|
||||
* Each slot (tile) has special action as drawing from the upper/lower row or taking food.
|
||||
*/
|
||||
private final List<Slot> slotList;
|
||||
|
||||
/** tribeDeck is the deck from where you draw tribe cards as characters and events. */
|
||||
private final Queue<TribeCard> tribeDeck;
|
||||
|
||||
/**
|
||||
* The upper row of tribe cards. It contains a total of
|
||||
* {@code nTotem + 4} tribe cards, which may include both character and event cards.
|
||||
*/
|
||||
private final List<TribeCard> upperListTribe;
|
||||
|
||||
/**
|
||||
* The lower row of the tribe card. During the first round, there will be (num. of players + 1) character cards.
|
||||
* During the following rounds, lower row will be emptied and populated with upper row's cards.
|
||||
* When an Event card gets in the lower row, the event effect will be activated at the end of the round.
|
||||
*/
|
||||
private final List<TribeCard> lowerListTribe;
|
||||
|
||||
/** Contains all the building cards of the upper list. When a new era starts, all its building cards are placed here. */
|
||||
private final List<BuildingCard> upperListBuilding;
|
||||
|
||||
/** Contains all the building cards of the lower list. When a new era starts, the old era's buildings are moved from the upper to the lower list. */
|
||||
private final List<BuildingCard> lowerListBuilding;
|
||||
|
||||
/**
|
||||
* Returns the upper row of tribe cards.
|
||||
*
|
||||
* @return the live upper tribe card list.
|
||||
*/
|
||||
<b class="fc"> public List<TribeCard> getUpperListTribe() { return upperListTribe; }</b>
|
||||
|
||||
/**
|
||||
* Returns the lower row of tribe cards.
|
||||
*
|
||||
* @return the live lower tribe card list.
|
||||
*/
|
||||
<b class="fc"> public List<TribeCard> getLowerListTribe() { return lowerListTribe; }</b>
|
||||
|
||||
/**
|
||||
* Returns the upper row of building cards.
|
||||
*
|
||||
* @return the live upper building card list.
|
||||
*/
|
||||
<b class="fc"> public List<BuildingCard> getUpperListBuilding() { return upperListBuilding; }</b>
|
||||
|
||||
/**
|
||||
* Returns the lower row of building cards.
|
||||
*
|
||||
* @return the live lower building card list.
|
||||
*/
|
||||
<b class="fc"> public List<BuildingCard> getLowerListBuilding() { return lowerListBuilding; }</b>
|
||||
|
||||
/** All building card lists grouped by era; index 0 = era 1, index 1 = era 2, etc. */
|
||||
private final ArrayList<List<BuildingCard>> buildingCardsAllEras;
|
||||
/** Number of players */
|
||||
private final int nTotem;
|
||||
|
||||
/** Current era of the game */
|
||||
private int era;
|
||||
|
||||
/**
|
||||
* Creates and returns a new list containing the slots (tiles) of the game.
|
||||
*
|
||||
* @return a copy of the slot list.
|
||||
*/
|
||||
public List<Slot> getSlotList(){
|
||||
<b class="fc"> return slotList.stream().map(x->new Slot(x.getSlotId())).collect(Collectors.toList());</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the size of the TribeDeck
|
||||
*/
|
||||
public int getTribeDeckSize() {
|
||||
<b class="fc"> return this.tribeDeck.size();</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the game era
|
||||
*/
|
||||
<b class="fc"> public int getEra() {return this.era;}</b>
|
||||
|
||||
|
||||
/**
|
||||
* Creates and initializes a new board:
|
||||
* - Generate the slotList using a method of DecksCreator.
|
||||
* - Generate the tribeDeck.
|
||||
* - Populate the lower list (if there is an event card, it's added to the upper list).
|
||||
* - Populate the upper list.
|
||||
* - Generate the buildingDeck using a method of DecksCreator.
|
||||
*
|
||||
* @param nTotem the number of players.
|
||||
*/
|
||||
<b class="fc"> public Board(int nTotem) {</b>
|
||||
<b class="fc"> this.nTotem = nTotem;</b>
|
||||
<b class="fc"> this.slotList = DecksCreator.loadSlotDeck().stream().filter(x->x.getNMinPlayer()<=nTotem).sorted(Comparator.comparingInt(Slot::getSlotId)).toList();</b>
|
||||
<b class="fc"> upperListTribe=new ArrayList<>();</b>
|
||||
<b class="fc"> lowerListTribe=new ArrayList<>();</b>
|
||||
<b class="fc"> lowerListBuilding=new ArrayList<>();</b>
|
||||
<b class="fc"> tribeDeck=generateTribeDeck(nTotem);</b>
|
||||
<b class="fc"> era=1;</b>
|
||||
|
||||
|
||||
<b class="fc"> for(int i=0;i<nTotem+1;i++)</b>
|
||||
{
|
||||
<b class="fc"> TribeCard tempCard = tribeDeck.remove();</b>
|
||||
<b class="fc"> if(tempCard.isEventCard())</b>
|
||||
{
|
||||
<b class="fc"> upperListTribe.add(tempCard);</b>
|
||||
<b class="fc"> i--;</b>
|
||||
}
|
||||
else
|
||||
{
|
||||
<b class="fc"> lowerListTribe.add(tempCard);</b>
|
||||
}
|
||||
}
|
||||
|
||||
<b class="fc"> for(int i=upperListTribe.size();i<nTotem+4;i++)</b>
|
||||
{
|
||||
<b class="fc"> TribeCard tempCard = tribeDeck.remove();</b>
|
||||
<b class="fc"> upperListTribe.add(tempCard);</b>
|
||||
}
|
||||
|
||||
<b class="fc"> ArrayList<BuildingCard> buildingDeck = new ArrayList<>(DecksCreator.loadBuildingDeckByEra(1));</b>
|
||||
<b class="fc"> Collections.shuffle(buildingDeck);</b>
|
||||
<b class="fc"> buildingCardsAllEras= new ArrayList<>();</b>
|
||||
<b class="fc"> buildingCardsAllEras.add(new ArrayList<>());</b>
|
||||
<b class="fc"> buildingCardsAllEras.add(new ArrayList<>());</b>
|
||||
<b class="fc"> buildingCardsAllEras.add(new ArrayList<>());</b>
|
||||
<b class="fc"> if(nTotem==2)</b>
|
||||
{
|
||||
<b class="fc"> buildingCardsAllEras.set(0, new ArrayList<>(buildingDeck.subList(0, 1)));</b>
|
||||
<b class="fc"> upperListBuilding = new ArrayList<>(buildingDeck.subList(0,1));</b>
|
||||
}
|
||||
else
|
||||
{
|
||||
<b class="fc"> buildingCardsAllEras.set(0, new ArrayList<>(buildingDeck.subList(0, 2)));</b>
|
||||
<b class="fc"> upperListBuilding = new ArrayList<>(buildingDeck.subList(0,2));</b>
|
||||
}
|
||||
|
||||
<b class="fc"> buildingDeck=new ArrayList<>(DecksCreator.loadBuildingDeckByEra(2));</b>
|
||||
<b class="fc"> Collections.shuffle(buildingDeck);</b>
|
||||
<b class="fc"> if(nTotem<=3)</b>
|
||||
{
|
||||
<b class="fc"> buildingCardsAllEras.set(1, new ArrayList<BuildingCard>(buildingDeck.subList(0, 2)));</b>
|
||||
}
|
||||
else
|
||||
{
|
||||
<b class="fc"> buildingCardsAllEras.set(1, new ArrayList<BuildingCard>(buildingDeck.subList(0, 3)));</b>
|
||||
}
|
||||
<b class="fc"> buildingDeck=new ArrayList<>(DecksCreator.loadBuildingDeckByEra(3));</b>
|
||||
<b class="fc"> Collections.shuffle(buildingDeck);</b>
|
||||
<b class="fc"> if(nTotem==2)</b>
|
||||
{
|
||||
<b class="fc"> buildingCardsAllEras.set(2, new ArrayList<BuildingCard>(buildingDeck.subList(0, 3)));</b>
|
||||
<b class="fc"> }else if(nTotem==5)</b>
|
||||
{
|
||||
<b class="fc"> buildingCardsAllEras.set(2, new ArrayList<BuildingCard>(buildingDeck.subList(0, 5)));</b>
|
||||
}
|
||||
else {
|
||||
<b class="fc"> buildingCardsAllEras.set(2, new ArrayList<BuildingCard>(buildingDeck.subList(0, 4)));</b>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tribeDeck. Loads the cards from each era, shuffle them, and then combine them in the final deck.
|
||||
* In the end, two special events (Sustenance and ShamanicRitual) are added.
|
||||
*
|
||||
* @param nPlayers the number of players.
|
||||
* @return a queue containing the cards in this order:
|
||||
* - Era 1.
|
||||
* - Era 2.
|
||||
* - Era 3.
|
||||
* - Special events.
|
||||
*/
|
||||
private Queue<TribeCard> generateTribeDeck(int nPlayers) {
|
||||
<b class="fc"> ArrayList<TribeCard> era1= DecksCreator.loadTribeDeckByEra(1).stream().filter(x->x.getNMin()<=nPlayers).collect(Collectors.toCollection(ArrayList::new));</b>
|
||||
<b class="fc"> ArrayList<TribeCard> era2= DecksCreator.loadTribeDeckByEra(2).stream().filter(x->x.getNMin()<=nPlayers).collect(Collectors.toCollection(ArrayList::new));</b>
|
||||
<b class="fc"> ArrayList<TribeCard> era3= DecksCreator.loadTribeDeckByEra(3).stream().filter(x->x.getNMin()<=nPlayers).collect(Collectors.toCollection(ArrayList::new));</b>
|
||||
<b class="fc"> Collections.shuffle(era1);</b>
|
||||
<b class="fc"> Collections.shuffle(era2);</b>
|
||||
<b class="fc"> Collections.shuffle(era3);</b>
|
||||
|
||||
<b class="fc"> Queue<TribeCard> tribeDeck_temp=new LinkedList<>();</b>
|
||||
<b class="fc"> tribeDeck_temp.addAll(era1);</b>
|
||||
<b class="fc"> tribeDeck_temp.addAll(era2);</b>
|
||||
<b class="fc"> tribeDeck_temp.addAll(era3);</b>
|
||||
<b class="fc"> tribeDeck_temp.add(new Sustenance("095",3,3));</b>
|
||||
<b class="fc"> tribeDeck_temp.add(new ShamanicRitual("096",3,15,7));</b>
|
||||
<b class="fc"> return tribeDeck_temp;</b>
|
||||
}
|
||||
|
||||
/** @return the queue of events cards from the lower list that need to be activated */
|
||||
public Queue<EventCard> getPendingEvents(){
|
||||
<b class="fc"> return lowerListTribe.stream().filter(TribeCard::isEventCard).map(x->(EventCard)x).collect(Collectors.toCollection(LinkedList::new));</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the selected card from the upper tribe list of the board.
|
||||
*
|
||||
* @param tribeCard is the card to remove.
|
||||
* @return true if the card is successfully removed.
|
||||
*/
|
||||
public boolean removeUpperTribeCard(TribeCard tribeCard) {
|
||||
<b class="fc"> return upperListTribe.remove(tribeCard);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the selected card from the lower tribe list of the board.
|
||||
*
|
||||
* @param tribeCard is the card to remove.
|
||||
* @return true if succeed in removing the card.
|
||||
*/
|
||||
public boolean removeLowerTribeCard(TribeCard tribeCard) {
|
||||
<b class="fc"> return lowerListTribe.remove(tribeCard);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the selected card from the upper building list of the board.
|
||||
*
|
||||
* @param buildingCard is the card to remove.
|
||||
* @return true if succeed in removing the card.
|
||||
*/
|
||||
public boolean removeUpperBuildingCard(BuildingCard buildingCard) {
|
||||
<b class="fc"> return upperListBuilding.remove(buildingCard);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the selected card from the lower building list of the board.
|
||||
*
|
||||
* @param buildingCard is the card to remove.
|
||||
* @return true if succeed in removing the card.
|
||||
*/
|
||||
public boolean removeLowerBuildingCard(BuildingCard buildingCard) {
|
||||
<b class="fc"> return lowerListBuilding.remove(buildingCard);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Goes to the next round.
|
||||
* - Clear the lower tribe row.
|
||||
* - Moves the upper tribe row to the lower one.
|
||||
* - Populate the upper tribe row.
|
||||
*
|
||||
* @return the current era after moving to the next round.
|
||||
*/
|
||||
public int nextRound() {
|
||||
<b class="fc"> lowerListTribe.clear();</b>
|
||||
<b class="fc"> lowerListTribe.addAll(upperListTribe);</b>
|
||||
<b class="fc"> upperListTribe.clear();</b>
|
||||
|
||||
<b class="fc"> for(int i=0;i<nTotem+4;i++)</b>
|
||||
{
|
||||
<b class="pc"> if (tribeDeck.isEmpty()) break;</b>
|
||||
<b class="fc"> TribeCard tempCard = tribeDeck.remove();</b>
|
||||
<b class="fc"> if(tempCard.getEra()!=era)</b>
|
||||
{
|
||||
<b class="fc"> nextEra();</b>
|
||||
}
|
||||
<b class="fc"> upperListTribe.add(tempCard);</b>
|
||||
}
|
||||
|
||||
<b class="fc"> return era;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the era of the game:
|
||||
* - Increase the era attribute.
|
||||
* - Clear the lower building list and replace it with the upper building list.
|
||||
* - Repopulate the upper building list.
|
||||
*/
|
||||
private void nextEra() {
|
||||
<b class="fc"> era=era+1;</b>
|
||||
<b class="fc"> lowerListBuilding.clear();</b>
|
||||
<b class="fc"> lowerListBuilding.addAll(upperListBuilding);</b>
|
||||
<b class="fc"> upperListBuilding.clear();</b>
|
||||
|
||||
<b class="fc"> if(era==2)</b>
|
||||
{
|
||||
<b class="fc"> upperListBuilding.addAll(buildingCardsAllEras.get(1));</b>
|
||||
}
|
||||
else
|
||||
{
|
||||
<b class="fc"> upperListBuilding.addAll(buildingCardsAllEras.get(2));</b>
|
||||
}
|
||||
}
|
||||
}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var msie = false, msie9 = false;
|
||||
/*@cc_on
|
||||
msie = true;
|
||||
@if (@_jscript_version >= 9)
|
||||
msie9 = true;
|
||||
@end
|
||||
@*/
|
||||
|
||||
if (!msie || msie && msie9) {
|
||||
hljs.highlightAll()
|
||||
hljs.initLineNumbersOnLoad();
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
<div class="footer">
|
||||
|
||||
<div style="float:right;">generated on 2026-06-19 22:53</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user