Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #265 from jsettlers/fixes_for_5062c1f
Browse files Browse the repository at this point in the history
Release preparation with several bug fixes in game logic.
  • Loading branch information
andreas-eberle committed Jan 7, 2016
2 parents 762338c + a6da068 commit e5efdee
Show file tree
Hide file tree
Showing 100 changed files with 1,099 additions and 601 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Declare files that will always have CRLF line endings on checkout.
*.prp text eol=crlf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ logs
/jsettlers.main.swing/*.log

/jsettlers.tests/out
/jsettlers.common/resources/.jsettlers
8 changes: 4 additions & 4 deletions go.graphics.android/.classpath
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/go.graphics"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
16 changes: 16 additions & 0 deletions go.graphics.android/.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,29 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
8 changes: 8 additions & 0 deletions go.graphics.android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="go.graphics.android"
android:versionCode="1"
android:versionName="1.0">

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" />

</manifest>
3 changes: 0 additions & 3 deletions jsettlers.common/resources/.jsettlers

This file was deleted.

4 changes: 2 additions & 2 deletions jsettlers.common/resources/buildings/baker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
<blocked dx="4" dy="5" block="false" />

<door dx="3" dy="2" />

<constructionStack dx="3" dy="5" material="PLANK" buildrequired="4" />
<constructionStack dx="5" dy="5" material="STONE" buildrequired="5" />
<constructionStack dx="4" dy="4" material="STONE" buildrequired="5" />
<requestStack dx="3" dy="4" material="FLOUR" />
<requestStack dx="4" dy="2" material="WATER" />
<offerStack dx="-2" dy="1" material="BREAD" />
Expand Down
29 changes: 6 additions & 23 deletions jsettlers.common/resources/buildings/dockyard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<ground groundtype="GRASS" />
<ground groundtype="EARTH" />
<ground groundtype="FLATTENED" />

<blocked dx="0" dy="0" block="true" />
<blocked dx="-2" dy="1" block="true" />
<blocked dx="-1" dy="1" block="true" />
Expand All @@ -26,7 +27,6 @@
<blocked dx="-2" dy="-2" block="true" />
<blocked dx="-2" dy="-3" block="true" />
<blocked dx="-2" dy="-4" block="true" />
<blocked dx="2" dy="0" block="true" />
<blocked dx="2" dy="-1" block="true" />
<blocked dx="1" dy="-2" block="true" />
<blocked dx="0" dy="-3" block="true" />
Expand All @@ -52,37 +52,20 @@
<blocked dx="1" dy="4" block="false" />
<blocked dx="2" dy="4" block="false" />
<blocked dx="3" dy="4" block="false" />
<blocked dx="-1" dy="4" block="false" />
<blocked dx="0" dy="5" block="false" />
<blocked dx="1" dy="6" block="false" />
<blocked dx="2" dy="6" block="false" />
<blocked dx="1" dy="5" block="false" />
<blocked dx="2" dy="5" block="false" />
<blocked dx="3" dy="6" block="false" />
<blocked dx="3" dy="5" block="false" />
<blocked dx="4" dy="5" block="false" />
<blocked dx="4" dy="3" block="false" />
<blocked dx="4" dy="4" block="false" />
<blocked dx="4" dy="6" block="false" />
<blocked dx="3" dy="0" block="false" />
<blocked dx="4" dy="2" block="false" />
<blocked dx="0" dy="-4" block="false" />
<blocked dx="1" dy="-3" block="false" />
<blocked dx="2" dy="-2" block="false" />
<blocked dx="-3" dy="1" block="false" />
<blocked dx="-2" dy="3" block="false" />
<blocked dx="-1" dy="5" block="false" />
<blocked dx="0" dy="6" block="false" />
<blocked dx="2" dy="0" block="false" />

<door dx="2" dy="0" />

<constructionStack dx="3" dy="4" material="STONE" buildrequired="4" />
<constructionStack dx="1" dy="4" material="PLANK" buildrequired="3" />
<constructionStack dx="3" dy="4" material="STONE" buildrequired="5" />

<requestStack dx="-2" dy="3" material="NO_MATERIAL" />
<requestStack dx="0" dy="6" material="NO_MATERIAL" />
<requestStack dx="1" dy="4" material="NO_MATERIAL" />
<requestStack dx="3" dy="6" material="NO_MATERIAL" />
<requestStack dx="4" dy="5" material="NO_MATERIAL" />
<requestStack dx="-2" dy="2" material="PLANK" />
<requestStack dx="0" dy="4" material="IRON" />

<bricklayer dx="-1" dy="3" direction="NORTH_EAST" />
<bricklayer dx="3" dy="1" direction="NORTH_WEST" />
Expand Down
2 changes: 1 addition & 1 deletion jsettlers.common/resources/buildings/ironmine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<door dx="0" dy="2" />

<constructionStack dx="0" dy="3" material="PLANK" buildrequired="4" />
<constructionStack dx="3" dy="5" material="STONE" buildrequired="1" />
<constructionStack dx="2" dy="4" material="STONE" buildrequired="1" />

<requestStack dx="3" dy="4" material="BREAD" />
<requestStack dx="3" dy="2" material="MEAT" />
Expand Down
23 changes: 18 additions & 5 deletions jsettlers.common/resources/buildings/lookout_tower.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<ground groundtype="EARTH" />
<ground groundtype="FLATTENED" />

<blocked dx="2" dy="1" block="true" />
<blocked dx="1" dy="0" block="true" />
<blocked dx="0" dy="-1" block="true" />
<blocked dx="-1" dy="-1" block="true" />
Expand All @@ -18,31 +17,44 @@
<blocked dx="2" dy="2" block="true" />
<blocked dx="2" dy="3" block="true" />
<blocked dx="1" dy="2" block="true" />
<blocked dx="2" dy="0" block="true" />
<blocked dx="1" dy="-1" block="true" />
<blocked dx="-1" dy="-2" block="true" />
<blocked dx="0" dy="-2" block="true" />

<blocked dx="1" dy="3" block="false" />
<blocked dx="2" dy="4" block="false" />
<blocked dx="3" dy="4" block="false" />
<blocked dx="3" dy="3" block="false" />
<blocked dx="3" dy="2" block="false" />
<blocked dx="3" dy="1" block="false" />
<blocked dx="2" dy="0" block="false" />
<blocked dx="1" dy="-1" block="false" />
<blocked dx="0" dy="-2" block="false" />
<blocked dx="-1" dy="-2" block="false" />
<blocked dx="-2" dy="-2" block="false" />
<blocked dx="-2" dy="-1" block="false" />
<blocked dx="-2" dy="0" block="false" />
<blocked dx="-2" dy="1" block="false" />
<blocked dx="-1" dy="2" block="false" />
<blocked dx="0" dy="3" block="false" />
<blocked dx="1" dy="4" block="false" />
<blocked dx="1" dy="-2" block="false" />
<blocked dx="2" dy="-1" block="false" />
<blocked dx="3" dy="0" block="false" />
<blocked dx="-1" dy="-3" block="false" />
<blocked dx="0" dy="-3" block="false" />
<blocked dx="-2" dy="-3" block="false" />
<blocked dx="2" dy="1" block="false" />

<door dx="2" dy="1" />

<constructionStack dx="1" dy="4" material="STONE" buildrequired="2" />
<constructionStack dx="3" dy="4" material="PLANK" buildrequired="3" />

<bricklayer dx="-1" dy="2" direction="NORTH_EAST" />
<bricklayer dx="1" dy="3" direction="NORTH_EAST" />
<bricklayer dx="3" dy="3" direction="NORTH_WEST" />
<bricklayer dx="3" dy="2" direction="NORTH_WEST" />

<flag dx="1" dy="-1" />

<buildmark dx="-1" dy="1" />
<buildmark dx="2" dy="3" />
<buildmark dx="2" dy="1" />
Expand All @@ -51,4 +63,5 @@
<image file="14" for="GUI" type="GUI" sequence="9" image="0"/>
<image file="13" type="SETTLER" for="FINAL" image="0" sequence="2"/>
<image file="13" type="SETTLER" for="BUILD" image="1" sequence="2"/>

</building>
4 changes: 2 additions & 2 deletions jsettlers.common/resources/buildings/pig_farm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@
<!-- real door is at dx="1" dy="2", but blocked -->
<door dx="0" dy="1" />

<constructionStack dx="1" dy="6" material="PLANK" buildrequired="1" />
<constructionStack dx="3" dy="6" material="STONE" buildrequired="1" />
<constructionStack dx="1" dy="6" material="PLANK" buildrequired="6" />
<constructionStack dx="3" dy="6" material="STONE" buildrequired="6" />
<requestStack dx="5" dy="5" material="CROP" />
<requestStack dx="3" dy="6" material="WATER" />
<!--<stack dx="-1" dy="4" material="PIG" buildrequired="0" /> -->
Expand Down
2 changes: 1 addition & 1 deletion jsettlers.common/resources/buildings/weaponsmith.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<blocked dx="1" dy="-2" block="true" />
<blocked dx="2" dy="-1" block="true" />
<blocked dx="3" dy="-1" block="true" />
<blocked dx="3" dy="0" block="true" />
<blocked dx="3" dy="0" block="false" />
<blocked dx="2" dy="0" block="true" />
<blocked dx="1" dy="0" block="true" />
<blocked dx="-2" dy="0" block="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ building_TOOLSMITH = Werkzeugschmiede
building_WEAPONSMITH = Waffenschmiede

building_FARM = Getreidehof
building_PIG_FARM = Schweinehof
building_PIG_FARM = Schweinefarm
building_DONKEY_FARM = Eselhof
building_MILL = Mühle
building_BAKER = Bäcker
Expand Down
Binary file added jsettlers.common/resources/maps/6playersfun.map
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions jsettlers.common/src/jsettlers/common/buildings/EBuildingType.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public enum EBuildingType {

public static final EBuildingType[] values = EBuildingType.values();
public static final int NUMBER_OF_BUILDINGS = values.length;
private static final EBuildingType[] MILITARY_BUILDINGS = {TOWER, BIG_TOWER, CASTLE};

public final int ordinal;

Expand Down Expand Up @@ -326,6 +327,10 @@ public RelativeStack[] getOfferStacks() {
return offerStacks;
}

public static EBuildingType[] getMilitaryBuildings() {
return MILITARY_BUILDINGS;
}

public boolean isMine() {
switch (this) {
case COALMINE:
Expand All @@ -337,6 +342,17 @@ public boolean isMine() {
}
}

public boolean isMilitaryBuilding() {
switch(this) {
case TOWER:
case BIG_TOWER:
case CASTLE:
return true;
default:
return false;
}
}

/**
* A (fast) method that allows us to check if this landscape type is allowed.
*
Expand Down
56 changes: 42 additions & 14 deletions jsettlers.common/src/jsettlers/common/map/shapes/FreeMapArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public final class FreeMapArea implements IMapArea {
private final boolean[][] areaMap;
private final int width;
private final int height;
private final ShortPoint2D upperLeftPosition;

/**
* @param positions
Expand All @@ -51,13 +52,13 @@ public FreeMapArea(List<ShortPoint2D> positions) {
this.positions = positions;
SRectangle bounds = getBounds(positions);

xOffset = bounds.xMin;
yOffset = bounds.yMin;
width = bounds.getWidth() + 1;
height = bounds.getHeight() + 1;
this.xOffset = bounds.xMin;
this.yOffset = bounds.yMin;
this.width = bounds.getWidth() + 1;
this.height = bounds.getHeight() + 1;

areaMap = new boolean[width][height];
setPositionsToMap(areaMap, positions);
this.areaMap = new boolean[width][height];
this.upperLeftPosition = setPositionsToMap(areaMap, positions);
}

/**
Expand All @@ -81,8 +82,8 @@ public FreeMapArea(List<ShortPoint2D> positions, int minX, int minY, int width,
this.width = width;
this.height = height;

areaMap = new boolean[width][height];
setPositionsToMap(areaMap, positions);
this.areaMap = new boolean[width][height];
this.upperLeftPosition = setPositionsToMap(areaMap, positions);
}

/**
Expand All @@ -106,10 +107,29 @@ private final static ArrayList<ShortPoint2D> convertRelative(ShortPoint2D pos, R
return list;
}

private final void setPositionsToMap(boolean[][] areaMap, List<ShortPoint2D> positions) {
/**
* Sets the positions to the map and returns the upper left position
*
* @param areaMap
* @param positions
* @return
*/
private final ShortPoint2D setPositionsToMap(boolean[][] areaMap, List<ShortPoint2D> positions) {
if (positions.isEmpty()) {
return null;
}

ShortPoint2D upperLeft = positions.get(0);

for (ShortPoint2D curr : positions) {
areaMap[getMapX(curr)][getMapY(curr)] = true;

if (curr.y < upperLeft.y || curr.y == upperLeft.y && curr.x < upperLeft.x) {
upperLeft = curr;
}
}

return upperLeft;
}

final int getMapY(ShortPoint2D pos) {
Expand Down Expand Up @@ -142,12 +162,17 @@ private final SRectangle getBounds(List<ShortPoint2D> positions) {

@Override
public final boolean contains(ShortPoint2D pos) {
return isValidPos(pos) && areaMap[getMapX(pos)][getMapY(pos)];
return contains(pos.x, pos.y);
}

public boolean contains(int x, int y) {
int dx = x - xOffset;
int dy = y - yOffset;

return isValidMapPos(dx, dy) && areaMap[dx][dy];
}

private final boolean isValidPos(ShortPoint2D pos) {
int dx = pos.x - xOffset;
int dy = pos.y - yOffset;
private final boolean isValidMapPos(int dx, int dy) {
return dx >= 0 && dy >= 0 && dx < width && dy < height;
}

Expand All @@ -172,6 +197,10 @@ final void setPosition(ShortPoint2D pos, boolean value) {
areaMap[getMapX(pos)][getMapY(pos)] = value;
}

public ShortPoint2D getUpperLeftPosition() {
return upperLeftPosition;
}

private final static class FreeMapAreaIterator implements Iterator<ShortPoint2D> {

private final FreeMapArea freeMapArea;
Expand Down Expand Up @@ -201,5 +230,4 @@ public final void remove() {
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
*
* @author michael
*/
public enum EAction {
public enum EMovableAction {
/**
* No action is performed and the settler is just standing.
*/
Expand Down
Loading

0 comments on commit e5efdee

Please sign in to comment.