Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
paulwedeck committed Sep 14, 2019
2 parents 0d0ec52 + 88ba0d9 commit 26330b5
Show file tree
Hide file tree
Showing 199 changed files with 6,261 additions and 5,672 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ buildscript {
dependencies {
classpath 'org.eclipse.jgit:org.eclipse.jgit:3.1.0.201310021548-r'
if (findProject(':jsettlers.main.android')) {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions go.graphics.swing/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'java'

def lwjgl_version="3.1.6"
def lwjgl_version="3.2.3"

dependencies {
implementation project(':go.graphics')
Expand All @@ -10,7 +10,7 @@ dependencies {
compile "org.lwjgl:lwjgl-glfw:"+lwjgl_version
compile "org.lwjgl:lwjgl-egl:"+lwjgl_version
compile "org.lwjgl:lwjgl-jawt:"+lwjgl_version
compile "org.joml:joml:1.9.15"
compile "org.joml:joml:1.9.17"

compile "org.lwjgl:lwjgl:"+lwjgl_version+":natives-linux"
compile "org.lwjgl:lwjgl:"+lwjgl_version+":natives-macos"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public void update(Graphics graphics) {
}

public void paint(Graphics graphics) {
surface = JAWTFunctions.JAWT_GetDrawingSurface(jawt.GetDrawingSurface(), canvas);
surface = JAWTFunctions.JAWT_GetDrawingSurface(canvas, jawt.GetDrawingSurface());

JAWTFunctions.JAWT_DrawingSurface_Lock(surface.Lock(), surface);
surfaceinfo = JAWTFunctions.JAWT_DrawingSurface_GetDrawingSurfaceInfo(surface.GetDrawingSurfaceInfo(), surface);
JAWTFunctions.JAWT_DrawingSurface_Lock(surface, surface.Lock());
surfaceinfo = JAWTFunctions.JAWT_DrawingSurface_GetDrawingSurfaceInfo(surface, surface.GetDrawingSurfaceInfo());
regenerateWindowInfo();

if (first_draw) {
Expand All @@ -108,10 +108,10 @@ public void paint(Graphics graphics) {

swapBuffers();
makeCurrent(false);
JAWTFunctions.JAWT_DrawingSurface_Unlock(surface.Unlock(), surface);
JAWTFunctions.JAWT_DrawingSurface_Unlock(surface, surface.Unlock());

JAWTFunctions.JAWT_DrawingSurface_FreeDrawingSurfaceInfo(surface.FreeDrawingSurfaceInfo(), surfaceinfo);
JAWTFunctions.JAWT_FreeDrawingSurface(jawt.FreeDrawingSurface(), surface);
JAWTFunctions.JAWT_DrawingSurface_FreeDrawingSurfaceInfo(surfaceinfo, surface.FreeDrawingSurfaceInfo());
JAWTFunctions.JAWT_FreeDrawingSurface(surface, jawt.FreeDrawingSurface());

if(fpsLimit == 0) repaint();
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public enum EActionType {
*/
SELECT_POINT_TYPE,

// - - - - - - SPEED - - - - -
/**
* Select only the wounded of the current selection.
*/
Expand All @@ -63,8 +64,6 @@ public enum EActionType {
* Skip the next minute of gameplay.
*/
FAST_FORWARD,

// - - - - - - SPEED - - - - -
/**
* Pauses or resumes the game.
*/
Expand All @@ -78,17 +77,9 @@ public enum EActionType {
*/
SPEED_SLOWER,
/**
* Sets the game speed to slow.
*/
SPEED_SLOW,
/**
* Sets the game speed to the default value.
*/
SPEED_NORMAL,
/**
* Sets the game speed to fast.
* Set speed
*/
SPEED_FAST,
SET_SPEED,

// - - - - - - SELECTION - - - - - - -
/**
Expand Down Expand Up @@ -169,7 +160,7 @@ public enum EActionType {
PAN_TO,

/**
* Toggles fog of war.
* Toggles fog of war if allowed by game rules.
*/
TOGGLE_FOG_OF_WAR,

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2018
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package jsettlers.common.action;

import jsettlers.common.movable.EMovableType;

/**
* This action is used to convert any movables to the given {@link EMovableType}.
*
* @author Andreas Eberle
*/
public class SetSpeedAction extends Action {

private final float speed;

/**
* This action is used to set the game speed.
*
* @param speed
* new speed to be set.
*/
public SetSpeedAction(float speed) {
super(EActionType.SET_SPEED);
this.speed = speed;
}

public float getSpeed() {
return speed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ public void setGameExitListener(IGameExitListener exitListener) {
public boolean isShutdownFinished() {
return false;
}

@Override
public boolean isMultiplayerGame() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ public interface IStartedGame {
void setGameExitListener(IGameExitListener exitListener);

boolean isShutdownFinished();

boolean isMultiplayerGame();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2019
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*******************************************************************************/
package jsettlers.common.player;

public enum EWinState {
UNDECIDED,
LOST,
WON,
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ public interface IInGamePlayer extends IPlayer {
* @return The civilisation the player has
*/
ECivilisation getCivilisation();

/**
* Get win/lose state for the player
* @return The win/lose state the player is in
*/
public EWinState getWinState();
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,32 @@ public interface IPlayer {

byte getTeamId();

EWinState getWinState();

class DummyPlayer implements IPlayer {
private final byte playerAndTeamid;
private final byte playerAndTeamId;

public DummyPlayer() {
this.playerAndTeamid = 0;
this.playerAndTeamId = 0;
}

public DummyPlayer(byte playerAndTeamid) {
this.playerAndTeamid = playerAndTeamid;
public DummyPlayer(byte playerAndTeamId) {
this.playerAndTeamId = playerAndTeamId;
}

@Override
public byte getPlayerId() {
return playerAndTeamid;
return playerAndTeamId;
}

@Override
public byte getTeamId() {
return playerAndTeamid;
return playerAndTeamId;
}

@Override
public EWinState getWinState() {
return EWinState.UNDECIDED;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
import jsettlers.common.selectable.ISelectionSet;
import go.graphics.FramerateComputer;
import jsettlers.common.statistics.IGameTimeProvider;
import jsettlers.common.player.IInGamePlayer;
import jsettlers.common.player.EWinState;
import jsettlers.graphics.action.ActionFireable;
import jsettlers.graphics.action.ActionHandler;
import jsettlers.graphics.action.ActionThreadBlockingListener;
Expand Down Expand Up @@ -211,6 +213,7 @@ private void eventDataChanged(float zoomFactor, UIPoint p) {
private ShortPoint2D lastSelectPointPos = null;

private UIPoint currentSelectionAreaStart;
private IInGamePlayer localPlayer;

public MapContent(IStartedGame game, SoundPlayer soundPlayer, ETextDrawPosition textDrawPosition) {
this(game, soundPlayer, textDrawPosition,null);
Expand Down Expand Up @@ -245,6 +248,7 @@ public MapContent(IStartedGame game, SoundPlayer soundPlayer, ETextDrawPosition
}
width = map.getWidth();
height = map.getHeight();
this.localPlayer = game.getInGamePlayer();
this.gameTimeProvider = game.getGameTimeProvider();
this.textDrawPosition = textDrawPosition;
this.messenger = new Messenger(this.gameTimeProvider);
Expand Down Expand Up @@ -324,6 +328,7 @@ public void drawContent(GLDrawContext gl, int newWidth, int newHeight) {
drawSelectionHint(gl);
controls.drawAt(gl);
drawMessages(gl);
drawWinStateMsg(gl);

drawFramerateTimeAndHash(gl);

Expand Down Expand Up @@ -368,6 +373,16 @@ private float messageAlpha(IMessage m) {
: Math.max(0, 1f - (float) age / IMessage.MESSAGE_TTL);
}

private void drawWinStateMsg(GLDrawContext gl) {
if(localPlayer.getWinState() == EWinState.UNDECIDED) {
return;
}
Color color = localPlayer.getWinState() == EWinState.WON ? Color.GREEN : Color.RED;
final String msg = Labels.getString("winstate_" + localPlayer.getWinState());
TextDrawer drawer = textDrawer.getTextDrawer(gl, EFontSize.HEADLINE);
drawer.drawString(windowWidth / 2, windowHeight - 2 * EFontSize.HEADLINE.getSize(), color, msg);
}

private void drawMessages(GLDrawContext gl) {
TextDrawer drawer = textDrawer.getTextDrawer(gl, EFontSize.HEADLINE);
int messageIndex = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ materials_overview_title = Lagerbestand
select_to_build = Wähle wo du das Gebäude (%s) bauen willst

#messages
winstate_WON = Sie haben gewonnen!
winstate_LOST = Sie haben verloren!
attacked = Sie werden angegriffen.
minerals_COAL = Ein Geologe hat Kohle gefunden.
minerals_IRONORE = Ein Geologe hat Eisen gefunden.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ materials_overview_title = Stocked Materials
select_to_build = Where do you want to build %s?

#messages
winstate_WON = You've won!
winstate_LOST = You've lost!
attacked = You have been attacked.
minerals_COAL = A geologist found coal.
minerals_IRONORE = A geologist found iron.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ materials_overview_title = Magazyn
select_to_build = Gdzie chcesz zbudować %s?

#messages
winstate_WON = Wygrałeś.
winstate_LOST = Przegrałeś.
attacked = Zostałeś zaatakowany.
minerals_COAL = Znaleziono węgiel.
minerals_IRONORE = Znaleziono żelazo.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 - 2017
* Copyright (c) 2015 - 2019
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
Expand Down Expand Up @@ -44,6 +44,7 @@
import jsettlers.common.movable.EMovableAction;
import jsettlers.common.movable.EMovableType;
import jsettlers.common.movable.IMovable;
import jsettlers.common.player.EWinState;
import jsettlers.common.player.IPlayer;
import jsettlers.common.position.RelativePoint;
import jsettlers.common.position.ShortPoint2D;
Expand Down Expand Up @@ -81,7 +82,8 @@
public class AiStatistics {

private static final EBuildingType[] REFERENCE_POINT_FINDER_BUILDING_ORDER = { LUMBERJACK, TOWER, BIG_TOWER, CASTLE };
public static final int NEAR_STONE_DISTANCE = 5;

private static final int NEAR_STONE_DISTANCE = 5;

private final MainGrid mainGrid;
private final Queue<Building> buildings;
Expand Down Expand Up @@ -183,9 +185,7 @@ private void updateNumberOfNotFinishedBuildings(PlayerStatistic playerStatistic,
playerStatistic.numberOfNotOccupiedMilitaryBuildings++;
}
} else if (building.getBuildingType().isMilitaryBuilding()) {
if (building.isOccupied()) {
playerStatistic.isAlive = true;
} else {
if (!building.isOccupied()) {
playerStatistic.numberOfNotOccupiedMilitaryBuildings++;
}
}
Expand Down Expand Up @@ -659,12 +659,13 @@ public AiPositions getOtherPartitionBorderOf(byte playerId) {
return playerStatistics[playerId].otherPartitionBorder;
}

private boolean isAlive(IPlayer player) {
return isAlive(player.getPlayerId());
public boolean isAlive(IPlayer player) {
return player.getWinState() != EWinState.LOST;
}

public boolean isAlive(byte playerId) {
return playerStatistics[playerId].isAlive;
IPlayer player = partitionsGrid.getPlayer(playerId);
return isAlive(player);
}

public AiMapInformation getAiMapInformation() {
Expand Down Expand Up @@ -708,7 +709,6 @@ public AiPositions getStonesNearBy(byte playerId) {

private static class PlayerStatistic {
ShortPoint2D referencePosition;
boolean isAlive;
final int[] totalBuildingsNumbers = new int[EBuildingType.NUMBER_OF_BUILDINGS];
final int[] buildingsNumbers = new int[EBuildingType.NUMBER_OF_BUILDINGS];
final Map<EBuildingType, List<ShortPoint2D>> buildingPositions = new HashMap<>();
Expand Down Expand Up @@ -740,7 +740,6 @@ private static class PlayerStatistic {
}

public void clearAll() {
isAlive = false;
materials = null;
buildingPositions.clear();
enemyTroopsInTown.clear();
Expand Down
Loading

0 comments on commit 26330b5

Please sign in to comment.