Skip to content

Commit

Permalink
Merge branch 'release/0.2.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
fabio-t committed Mar 3, 2018
2 parents b481215 + 9a0eabf commit 3e7abe0
Show file tree
Hide file tree
Showing 16 changed files with 256 additions and 55 deletions.
2 changes: 1 addition & 1 deletion alone-rl.iml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<orderEntry type="library" name="Maven: net.onedaybeard.artemis:artemis-odb:2.1.0" level="project" />
<orderEntry type="library" name="Maven: net.mostlyoriginal.artemis-odb:contrib-core:2.3.0" level="project" />
<orderEntry type="library" name="Maven: com.github.fabio-t:rlforj-alt:0.3.0" level="project" />
<orderEntry type="library" name="Maven: com.github.fabio-t:terrain-generator:0.1.0" level="project" />
<orderEntry type="library" name="Maven: com.github.fabio-t:terrain-generator:0.1.1" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.3.0-alpha4" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.3.0-alpha4" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.8.0-beta1" level="project" />
Expand Down
18 changes: 15 additions & 3 deletions data/crafting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sharp-stone:
sources: stone
tools: stone

small-sharp-stone:
stone-knife:
sources: sharp-stone
tools: stone

Expand All @@ -16,5 +16,17 @@ stone-axe:
tools: stone

stone-spear:
sources: [small-sharp-stone, trunk, vine]
tools: stone
sources: [stone-knife, trunk, vine]
tools: [stone-axe, stone-knife]

arrow:
sources: branch
tools: stone-knife

stone-arrow:
sources: [stone-knife, branch, vine]
tools: stone-knife

bow:
sources: [trunk, vine]
tools: [stone-axe, stone-knife]
51 changes: 48 additions & 3 deletions data/items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ sharp-stone:
blue: 88
alpha: 255

small-sharp-stone:
name: a small, sharp stone
stone-knife:
name: a stone knife
wearable:
where: HANDS
weapon:
Expand Down Expand Up @@ -143,7 +143,52 @@ stone-spear:
damageType: POINT
damage: 4
sprite:
c: 244
c: 124
col:
red: 141
green: 104
blue: 21
alpha: 255

arrow:
name: an arrow
weapon:
damageType: POINT
damage: 2
ammo:
usableBy: bow
sprite:
c: 196
col:
red: 141
green: 104
blue: 21
alpha: 255

stone-arrow:
name: a stone-tip arrow
weapon:
damageType: POINT
damage: 3
ammo:
usableBy: bow
sprite:
c: 26
col:
red: 141
green: 104
blue: 21
alpha: 255

bow:
name: a simple bow
wearable:
where: HANDS
weapon:
damageType: SHOOTER
damage: 1
sprite:
c: '('
col:
red: 141
green: 104
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>com.github.fabio-t</groupId>
<artifactId>alone-rl</artifactId>
<version>0.2.6</version>
<version>0.2.7</version>
<packaging>jar</packaging>

<name>AloneRL</name>
Expand Down Expand Up @@ -59,7 +59,7 @@
<dependency>
<groupId>com.github.fabio-t</groupId>
<artifactId>terrain-generator</artifactId>
<version>0.1.0</version>
<version>0.1.1</version>
</dependency>

<dependency>
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/com/github/fabioticconi/alone/components/Ammo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2015-2018 Fabio Ticconi
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package com.github.fabioticconi.alone.components;

import com.artemis.Component;

/**
* Author: Fabio Ticconi
* Date: 02/03/18
*/
public class Ammo extends Component
{
public String usableBy;

public Ammo()
{

}

public Ammo(final String usableBy)
{
this.usableBy = usableBy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package com.github.fabioticconi.alone.components;

import com.artemis.Component;
import com.github.fabioticconi.alone.constants.WeaponType;
import com.github.fabioticconi.alone.constants.DamageType;

import java.util.EnumMap;

Expand All @@ -29,22 +29,22 @@
*/
public class Armour extends Component
{
// TODO we can improve this by using a primitive float array and WeaponType ordinals as indeces.
// TODO we can improve this by using a primitive float array and DamageType ordinals as indeces.
// which is what EnumMap does internally. We'd avoid autoboxing.
public final EnumMap<WeaponType, Float> defences;
public final EnumMap<DamageType, Float> defences;

public Armour()
{
this.defences = new EnumMap<>(WeaponType.class);
this.defences = new EnumMap<>(DamageType.class);
}

public void set(final float slash, final float point, final float blunt, final float natural)
{
this.defences.put(WeaponType.SLASH, slash);
this.defences.put(WeaponType.POINT, point);
this.defences.put(WeaponType.BLUNT, blunt);
this.defences.put(DamageType.SLASH, slash);
this.defences.put(DamageType.POINT, point);
this.defences.put(DamageType.BLUNT, blunt);

// a generic type for animal attacks
this.defences.put(WeaponType.NATURAL, natural);
this.defences.put(DamageType.NATURAL, natural);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@
package com.github.fabioticconi.alone.components;

import com.artemis.Component;
import com.github.fabioticconi.alone.constants.WeaponType;
import com.github.fabioticconi.alone.constants.DamageType;

/**
* Author: Fabio Ticconi
* Date: 07/10/17
*/
public class Weapon extends Component
{
public WeaponType damageType;
public DamageType damageType;
public float damage;

public Weapon()
{

}

public Weapon(final WeaponType damageType, final float damage)
public Weapon(final DamageType damageType, final float damage)
{
set(damageType, damage);
}

public void set(final WeaponType damageType, final float damage)
public void set(final DamageType damageType, final float damage)
{
this.damageType = damageType;
this.damage = damage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
* Author: Fabio Ticconi
* Date: 04/11/17
*/
public enum WeaponType
public enum DamageType
{
SLASH,
POINT,
BLUNT,
NATURAL
NATURAL,
SHOOTER
}
51 changes: 51 additions & 0 deletions src/main/java/com/github/fabioticconi/alone/messages/ShootMsg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2015-2018 Fabio Ticconi
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package com.github.fabioticconi.alone.messages;

import com.github.fabioticconi.alone.constants.Side;

import java.awt.*;

/**
* Author: Fabio Ticconi
* Date: 01/11/17
*/
public class ShootMsg extends AbstractMessage
{
public final String item;
public final Side at;

public ShootMsg(final String item, final Side at)
{
this.item = item;
this.at = at;
}

@Override
public String format()
{
fgCol = Color.RED;

return String.format("%s %s %s towards %s",
actor,
thirdPerson ? "shoots" : "shoot",
item.toLowerCase(),
at.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ void regenerate()
final int seed = (int) (System.currentTimeMillis() / 1000);
final float freq = 3f / Math.max(Options.MAP_SIZE_X, Options.MAP_SIZE_Y);

final HeightMap heightMap = new HeightMap().size(Options.MAP_SIZE_X, Options.MAP_SIZE_Y)
.island(0.85f)
.rivers(0.8f, 0.03f, 0.001f);
final HeightMap heightMap = new HeightMap()
.size(Options.MAP_SIZE_X, Options.MAP_SIZE_Y)
.island(0.85f)
.rivers(0.8f, 0.03f, 0.001f, 1);

heightMap.fractalNoise
.seed(seed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import com.github.fabioticconi.alone.Main;
import com.github.fabioticconi.alone.components.*;
import com.github.fabioticconi.alone.components.attributes.Sight;
import com.github.fabioticconi.alone.constants.DamageType;
import com.github.fabioticconi.alone.constants.Side;
import com.github.fabioticconi.alone.constants.WeaponType;
import com.github.fabioticconi.alone.messages.AbstractMessage;
import com.github.fabioticconi.alone.messages.CannotMsg;
import com.github.fabioticconi.alone.messages.Msg;
Expand Down Expand Up @@ -193,7 +193,7 @@ else if (keys.get(KeyEvent.VK_T))
{
keys.clear();

final int weaponId = sItems.getWeapon(playerId, EnumSet.allOf(WeaponType.class), true);
final int weaponId = sItems.getWeapon(playerId, EnumSet.allOf(DamageType.class), true);

if (weaponId < 0)
{
Expand All @@ -204,6 +204,10 @@ else if (keys.get(KeyEvent.VK_T))

return 0f;
}

Main.pause();

screen.select(LookScreen.class);
}
else if (keys.get(KeyEvent.VK_W))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.github.fabioticconi.alone.components.attributes.Agility;
import com.github.fabioticconi.alone.components.attributes.Skin;
import com.github.fabioticconi.alone.components.attributes.Strength;
import com.github.fabioticconi.alone.constants.WeaponType;
import com.github.fabioticconi.alone.constants.DamageType;
import com.github.fabioticconi.alone.messages.DamageMsg;
import com.github.fabioticconi.alone.messages.KillMsg;
import com.github.fabioticconi.alone.messages.MissMsg;
Expand All @@ -35,6 +35,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.EnumSet;
import java.util.Random;

/**
Expand Down Expand Up @@ -137,23 +138,28 @@ public void doAction()

if (r.nextFloat() < toHit)
{
float damage = cStrength.value + 2f;
float armour = tSkin.value;

// assuming the actor is unharmed, we use a generic "natural" attack
WeaponType dmgType = WeaponType.NATURAL;
float damage = cStrength.value + 2f;
float armour = tSkin.value;
DamageType dmgType = DamageType.NATURAL;

// the weapon damage is added to the strength-based one, so that creatures
// wielding weapons can overcome stronger, unharmed creatures
final int weaponId = sItem.getWeapon(actorId);
final int weaponId = sItem.getWeapon(actorId, EnumSet.allOf(DamageType.class), true);
if (weaponId >= 0)
{
final Weapon w = mWeapon.get(weaponId);
damage += w.damage;
dmgType = w.damageType;
}
// or maybe we ARE a weapon (eg, if thrown or shot)
else if (mWeapon.has(actorId))
{
final Weapon w = mWeapon.get(actorId);
damage += w.damage;
dmgType = w.damageType;
}

final int armourId = sItem.getArmour(targetId);
final int armourId = sItem.getArmour(targetId, true);
if (armourId >= 0)
{
final Armour a = mArmour.get(armourId);
Expand Down
Loading

0 comments on commit 3e7abe0

Please sign in to comment.