-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rifle #2
Open
theazuresoul
wants to merge
6
commits into
master
Choose a base branch
from
rifle
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Rifle #2
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
776d224
Created rifle class
theazuresoul 1fce5ce
Created Snap Shot passive ability
theazuresoul d33087e
Created rifle attack action
theazuresoul ef47ab9
Added Snap Shot unit test
theazuresoul 8daf90f
Added rifle requirement to Precision Shot
theazuresoul a364097
Added Precision Shot weapon requirement unit test
theazuresoul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
core/src/main/java/com/pipai/wf/battle/action/RifleAttackAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.pipai.wf.battle.action; | ||
|
||
import com.pipai.wf.battle.agent.Agent; | ||
import com.pipai.wf.battle.damage.DamageCalculator; | ||
import com.pipai.wf.battle.damage.DamageResult; | ||
import com.pipai.wf.battle.damage.PercentageModifier; | ||
import com.pipai.wf.battle.damage.PercentageModifierList; | ||
import com.pipai.wf.battle.damage.TargetedActionCalculator; | ||
import com.pipai.wf.battle.damage.WeaponDamageFunction; | ||
import com.pipai.wf.battle.log.BattleEvent; | ||
import com.pipai.wf.battle.weapon.Weapon; | ||
import com.pipai.wf.exception.IllegalActionException; | ||
import com.pipai.wf.unit.ability.SnapShotAbility; | ||
|
||
public class RifleAttackAction extends RangedWeaponAttackAction{ | ||
|
||
public RifleAttackAction(Agent performerAgent, Agent targetAgent) { | ||
super(performerAgent, targetAgent); | ||
} | ||
|
||
@Override | ||
public PercentageModifierList getHitCalculation() { | ||
Agent a = getPerformer(); | ||
Agent target = getTarget(); | ||
PercentageModifierList p = TargetedActionCalculator.baseHitCalculation(a, target); | ||
if (a.hasUsedAP() && a.getAbilities().hasAbility(SnapShotAbility.class)) { | ||
p.add(new PercentageModifier("Snap Shot", -10)); | ||
} | ||
return p; | ||
} | ||
|
||
@Override | ||
protected void performImpl() throws IllegalActionException { | ||
Agent a = getPerformer(); | ||
Agent target = getTarget(); | ||
Weapon w = a.getCurrentWeapon(); | ||
if (!a.getAbilities().hasAbility(SnapShotAbility.class) && a.hasUsedAP()) { | ||
throw new IllegalActionException("Cannot fire rifle after moving"); | ||
} | ||
if (w.needsAmmunition() && w.currentAmmo() == 0) { | ||
throw new IllegalActionException("Not enough ammo to fire " + w.name()); | ||
} | ||
DamageResult result = DamageCalculator.rollDamageGeneral(this, new WeaponDamageFunction(w), 0); | ||
a.setAP(0); | ||
target.takeDamage(result.damage); | ||
log(BattleEvent.rangedWeaponAttackEvent(a, target, w, result)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.pipai.wf.battle.weapon; | ||
|
||
import com.pipai.wf.battle.action.RifleAttackAction; | ||
import com.pipai.wf.battle.action.TargetedAction; | ||
import com.pipai.wf.battle.action.TargetedActionable; | ||
import com.pipai.wf.battle.agent.Agent; | ||
import com.pipai.wf.math.LinearFunction; | ||
|
||
public class Rifle extends Weapon implements TargetedActionable { | ||
|
||
@Override | ||
public int flatAimModifier() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int rangeAimModifier(float distance) { | ||
int minOptimalRange = 7; | ||
int maxRangePenalty = -20; | ||
|
||
if (distance <= minOptimalRange) { | ||
return (int) (new LinearFunction(minOptimalRange, 0, 0, maxRangePenalty).eval(distance)); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
@Override | ||
public int flatCritProbabilityModifier() { | ||
return 20; | ||
} | ||
|
||
@Override | ||
public int rangeCritModifier(float distance) { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int minBaseDamage() { | ||
return 4; | ||
} | ||
|
||
@Override | ||
public int maxBaseDamage() { | ||
return 6; | ||
} | ||
|
||
@Override | ||
public boolean needsAmmunition() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public int baseAmmoCapacity() { | ||
return 3; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return "Rifle"; | ||
} | ||
|
||
@Override | ||
public TargetedAction getAction(Agent performer, Agent target) { | ||
return new RifleAttackAction(performer, target); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
core/src/main/java/com/pipai/wf/unit/ability/SnapShotAbility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.pipai.wf.unit.ability; | ||
|
||
public class SnapShotAbility extends PassiveAbility { | ||
|
||
public SnapShotAbility() { | ||
super(0); | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return "Snap Shot"; | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "Can fire rifle after moving with -10 to-hit penalty"; | ||
} | ||
|
||
@Override | ||
public Ability clone() { | ||
return new SnapShotAbility(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curly brace