Skip to content

Commit

Permalink
Merge pull request #80 from sheepsy90/master
Browse files Browse the repository at this point in the history
Release Candidate merge
  • Loading branch information
sheepsy90 authored May 18, 2018
2 parents 08fec5c + c50a0e6 commit 645e956
Show file tree
Hide file tree
Showing 31 changed files with 362 additions and 387 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ The sources mentioned in some sections of this document are available at

- [x] Removal of Illegal Defense and Illegal Attack
- [x] Allow Adult league to play drop in 2 vs. 2
- [ ] Skip extra time in knockout games
- [ ] Fix point counting on drop in challenge
- [ ] Fix "GameController goes to extended time even in normal mode"
- [ ] Highlight and make "current goalkeeper" changeable in UI
- [x] Skip extra time in knockout games
- [x] Fix point counting on drop in challenge
- [x] Fix "GameController goes to extended time even in normal mode"
- [x] Highlight and make "current goalkeeper" changeable in UI

_See [CHANGELOG](CHANGELOG.md) for more details and history._

Expand Down
4 changes: 2 additions & 2 deletions src/controller/action/ui/ClockPause.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public void perform(AdvancedData data)
data.manPlay = false;
} else {
data.manWhenClockChanged = data.getTime();
data.manPause = true;
data.setManualPause(true);
}
Log.state(data, "Time manual paused");
} else {
if (data.manPause) {
data.manPause = false;
data.setManualPause(false);
data.manTimeOffset -= data.getTime() - data.manWhenClockChanged;
} else {
data.manWhenClockChanged = data.getTime();
Expand Down
1 change: 1 addition & 0 deletions src/controller/action/ui/DirectFreeKick.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void perform(AdvancedData data)
data.secGameStateInfo.reset();
data.gameClock.clearSecondaryClock();
Log.setNextMessage("End DirectFreeKick " + data.team[side].teamColor.toString());
data.gameClock.addExtraClock("Direct Free Kick", 10);
ActionBoard.clockPause.perform(data);
}
}
Expand Down
39 changes: 39 additions & 0 deletions src/controller/action/ui/DropInPointsEvaluation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package controller.action.ui;

import controller.action.ActionType;
import controller.action.GCAction;
import data.PlayerInfo;
import data.states.AdvancedData;
import data.values.GameTypes;
import data.values.Penalties;
import data.values.Side;

public class DropInPointsEvaluation extends GCAction {

private final Side scoring_side;

public DropInPointsEvaluation(Side scoring_side) {
super(ActionType.UI);
this.scoring_side = scoring_side;
}

@Override
public void perform(AdvancedData data) {
for(PlayerInfo pi : data.getTeam(this.scoring_side).player){
if (pi.penalty == Penalties.NONE) {
pi.dropInPoints += 1;
}
}

for(PlayerInfo pi : data.getTeam(this.scoring_side.getOther()).player){
pi.dropInPoints -= 1;
}

data.gameClock.addExtraClock("Add point for scoring robot!", 10);
}

@Override
public boolean isLegal(AdvancedData data) {
return true;
}
}
31 changes: 31 additions & 0 deletions src/controller/action/ui/DropinPointDelta.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package controller.action.ui;

import controller.action.ActionType;
import controller.action.GCAction;
import data.states.AdvancedData;
import data.values.GameTypes;
import data.values.Side;

public class DropinPointDelta extends GCAction {

private final Side side;
private final int player;
private final int delta;

public DropinPointDelta(Side side, int player, int delta) {
super(ActionType.UI);
this.player = player;
this.side = side;
this.delta = delta;
}

@Override
public void perform(AdvancedData data) {
data.getTeam(this.side).player[this.player].dropInPoints += this.delta;
}

@Override
public boolean isLegal(AdvancedData data) {
return data.gameType == GameTypes.DROPIN || data.testmode;
}
}
14 changes: 14 additions & 0 deletions src/controller/action/ui/Goal.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import controller.action.GCAction;
import data.states.AdvancedData;
import data.values.GameStates;
import data.values.GameTypes;
import data.values.SecondaryGameStates;
import data.values.Side;


/**
Expand Down Expand Up @@ -44,6 +46,18 @@ public Goal(int side, int set)
@Override
public void perform(AdvancedData data)
{
// If we are in a dropin game we want to count dropin points
// We are doing this here with forwarding an action to later call the action directly
// from the button click of a score goal
if (data.gameType == GameTypes.DROPIN){
if (this.set > 0){
new DropInPointsEvaluation(Side.getFromInt(this.side)).perform(data);
} else {
new DropInPointsEvaluation(Side.getFromInt(this.side).getOther()).perform(data);
}
}

// Normal goal action
data.team[side].score += set;
if (set == 1) {
if (data.secGameState != SecondaryGameStates.PENALTYSHOOT) {
Expand Down
1 change: 1 addition & 0 deletions src/controller/action/ui/IndirectFreeKick.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void perform(AdvancedData data)
data.secGameStateInfo.reset();
data.gameClock.clearSecondaryClock();
Log.setNextMessage("End IndirectFreeKick " + data.team[side].teamColor.toString());
data.gameClock.addExtraClock("Indirect Free Kick", 10);
ActionBoard.clockPause.perform(data);
}
}
Expand Down
58 changes: 34 additions & 24 deletions src/controller/action/ui/half/FirstHalfOvertime.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,25 @@

/**
* @author Michel Bartsch
*
* <p>
* This action means that the half is to be set to the first half.
*/
public class FirstHalfOvertime extends GCAction
{
public class FirstHalfOvertime extends GCAction {
/**
* Creates a new FirstHalf action.
* Look at the ActionBoard before using this.
*/
public FirstHalfOvertime()
{
public FirstHalfOvertime() {
super(ActionType.UI);
}

/**
* Performs this action to manipulate the data (model).
*
* @param data The current data to work on.
*
* @param data The current data to work on.
*/
@Override
public void perform(AdvancedData data)
{
public void perform(AdvancedData data) {
if (data.firstHalf != GameControlData.C_TRUE || data.secGameState == SecondaryGameStates.PENALTYSHOOT) {
data.firstHalf = GameControlData.C_TRUE;
data.secGameState = SecondaryGameStates.OVERTIME;
Expand All @@ -44,25 +41,38 @@ public void perform(AdvancedData data)
Log.state(data, "1st Half Extra Time");
}
}

/**
* Checks if this action is legal with the given data (model).
* Illegal actions are not performed by the EventHandler.
*
* @param data The current data to check with.
*
* @param data The current data to check with.
*/
@Override
public boolean isLegal(AdvancedData data)
{
return ((data.firstHalf == GameControlData.C_TRUE)
&& (data.secGameState == SecondaryGameStates.OVERTIME))
|| ((Rules.league.overtime)
&& (data.gameType == GameTypes.PLAYOFF)
&& (data.secGameState == SecondaryGameStates.NORMAL)
&& (data.gameState == GameStates.FINISHED)
&& (data.firstHalf != GameControlData.C_TRUE)
&& (data.team[0].score == data.team[1].score)
&& (data.team[0].score > 0))
|| (data.testmode);
public boolean isLegal(AdvancedData data) {
if (data.gameType == GameTypes.ROUNDROBIN){
return false;
}

if (data.testmode) {
return true;
}

if ((Rules.league.overtime)
&& (data.gameType == GameTypes.PLAYOFF)
&& (data.secGameState == SecondaryGameStates.NORMAL)
&& (data.gameState == GameStates.FINISHED)
&& (data.firstHalf != GameControlData.C_TRUE)
&& (data.team[0].score == data.team[1].score)
&& (data.team[0].score > 0)) {
return true;
}

if (data.firstHalf == GameControlData.C_TRUE
&& (data.secGameState == SecondaryGameStates.OVERTIME)) {
return true;
}

return false;
}
}
12 changes: 6 additions & 6 deletions src/controller/action/ui/half/PenaltyShoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ public void perform(AdvancedData data)
@Override
public boolean isLegal(AdvancedData data)
{
// Penalty shootout is not possible in round robin
if (data.gameType == GameTypes.ROUNDROBIN){
return false;
}

return (data.secGameState == SecondaryGameStates.PENALTYSHOOT)
|| (data.previousSecGameState == SecondaryGameStates.PENALTYSHOOT)
|| ((data.firstHalf != GameControlData.C_TRUE)
&& (data.gameState == GameStates.FINISHED)
&& !(Rules.league.overtime
&& (data.gameType == GameTypes.PLAYOFF)
&& (data.secGameState == SecondaryGameStates.NORMAL)
&& (data.team[0].score == data.team[1].score)
&& (data.team[0].score > 0)) )
&& (data.gameState == GameStates.FINISHED))
|| (data.testmode);
}
}
2 changes: 2 additions & 0 deletions src/controller/ui/helper/FontHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ static public Font boldStandardFont(){

protected static final int TIME_FONT_SIZE = 50;
protected static final int TIME_SUB_FONT_SIZE = 40;
protected static final int TIME_EXTRA_CLOCK_SIZE = 20;

public static Font timeFont = new Font(STANDARD_FONT, Font.PLAIN, TIME_FONT_SIZE);
public static Font timeSubFont = new Font(STANDARD_FONT, Font.PLAIN, TIME_SUB_FONT_SIZE);
public static Font extraClockFont = new Font(STANDARD_FONT, Font.PLAIN, TIME_EXTRA_CLOCK_SIZE);

static public Font boldHeadlineFont(){
return new Font(STANDARD_FONT, Font.BOLD, HEADLINE_FONT_SIZE);
Expand Down
Loading

0 comments on commit 645e956

Please sign in to comment.