use of eidolons.system.graphics.PhaseAnimation in project Eidolons by IDemiurge.
the class RollMaster method roll.
/**
* @return true if {failure} formula rolls more, false otherwise
*/
public static boolean roll(ROLL_TYPES roll_type, String success, String fail, Ref ref, String logAppendix, String rollSource, Boolean logged) {
Obj source = ref.getSourceObj();
Obj target = ref.getTargetObj();
// if (roll == null)
roll = new Roll(roll_type, success, fail, 0);
if (StringMaster.isEmpty(fail)) {
fail = initStdFail(roll_type);
}
Formula failFormula = new Formula(fail);
if (source != null) {
failFormula.applyFactor(getFailFactor(roll_type));
}
Boolean result;
int max1 = failFormula.getInt(ref);
if (StringMaster.isEmpty(success)) {
success = initStdSuccess(roll_type);
}
Formula successFormula = new Formula(success);
successFormula.applyFactor(getSuccessFactor(roll_type));
int max2 = successFormula.getInt(ref);
int min1 = MathMaster.applyMod(max1, DEFAULT_MIN_ROLL_PERC);
int min2 = MathMaster.applyMod(max2, DEFAULT_MIN_ROLL_PERC);
if (min1 >= max2) {
return true;
}
if (min2 >= max1) {
return false;
}
// per die?
rolledValue = RandomWizard.getRandomIntBetween(min1, max1);
rolledValue2 = RandomWizard.getRandomIntBetween(min2, max2);
roll.setRolledValue(rolledValue);
roll.setRolledValue2(rolledValue2);
result = rolledValue > rolledValue2;
if (target == null) {
target = ref.getEvent().getRef().getTargetObj();
}
// TODO display roll formulas if FULL_INFO is on!
if (rollSource == null) {
rollSource = rolledValue + " out of " + max1;
} else {
rollSource += StringMaster.wrapInParenthesis(rolledValue + " out of " + max1);
}
String rollTarget = rolledValue2 + " out of " + max2;
logString = target.getName() + ((result) ? " fails" : " wins") + " a " + roll_type.getName() + " roll with " + rollTarget + " vs " + source.getName() + "'s " + rollSource;
if (logAppendix != null) {
if (isAppendixAdded(logAppendix, result)) {
logString = logString + logAppendix.replace(getSuccessAppendixIdentifier(), "");
}
}
if (logged == null) {
logged = checkRollLogged(roll_type, result);
}
if (logged) {
ref.getGame().getLogManager().log(logString);
}
ref.getGame().getLogManager();
ref.getGame().getLogManager();
if (!ref.isAnimationDisabled()) {
PhaseAnimation anim = null;
if (ref.getActive() != null) {
// else ?
anim = ((DC_ActiveObj) ref.getActive()).getAnimation();
}
if (anim != null) {
anim.addPhaseArgs(PHASE_TYPE.ROLL, roll);
}
}
roll.setResult(result);
roll.setLogAppendix(logAppendix);
roll.setRollSource(rollSource);
roll.setRollTarget(rollTarget);
return result;
}
use of eidolons.system.graphics.PhaseAnimation in project Eidolons by IDemiurge.
the class DC_PagedLogPanel method addComponents.
protected void addComponents() {
String pos = "pos 0 0";
add(getCurrentComponent(), pos);
addControls();
returnButton = new CustomButton(VISUALS.ADD) {
public void handleClick() {
back();
}
protected void playClickSound() {
DC_SoundMaster.playStandardSound(STD_SOUNDS.SLING);
}
public VISUALS getVisuals() {
if (!isEnabled()) {
return VISUALS.ADD_BLOCKED;
}
return super.getVisuals();
}
public boolean isEnabled() {
// nodeViewMode
return true;
}
};
// toggleButton = new CustomButton(BUTTON_VISUALS) {
// public void handleClick() {
// toggleMode();
// }
//
// protected void playSound() {
// DC_SoundMaster.playStandardSound(STD_SOUNDS.CLOCK);
// }
//
// };
//
// pos = "pos " + (getPanelWidth() - BUTTON_VISUALS.getWidth()) + " "
// + (getPanelHeight() - BUTTON_VISUALS.getHeight()) + "";
// add(toggleButton, pos);
pos = "pos 0 0";
add(returnButton, pos);
int i = 0;
if (entryNodes != null) {
for (final LogEntryNode node : entryNodes) {
int lineIndex = (node.getLineIndex()) % getRowCount();
if (lineIndex == 0) {
lineIndex = getRowCount();
}
Integer y = Math.min(getPanelHeight() - EntryNodeMaster.getRowHeight(isTopPage()), EntryNodeMaster.getRowHeight(isTopPage()) * (lineIndex));
// TODO
// top
// vs
// generic
// separate!
ImageButton entryNodeButton = new ImageButton((node.getButtonImagePath())) {
@Override
public void handleClick() {
if (entryNode == null) {
setCachedTopPageIndex(getCurrentIndex());
}
if (node.getLinkedAnimation() != null) {
for (ANIM anim : node.getLinkedAnimations()) {
PhaseAnimation animation = (PhaseAnimation) anim;
// DC_Game.game.getAnimationManager()
// .getAnimation(key);
animation.setPhaseFilter(node.getAnimPhasesToPlay());
if (animation != null) {
animation.setReplay(true);
animation.start();
animation.setAutoFinish(false);
}
}
Coordinates bufferedOffset = game.getAnimationManager().updatePoints();
game.getManager().refreshGUI();
game.getBattleField().getGrid().setNextOffsetCoordinate(bufferedOffset);
}
setNodeView(node);
}
@Override
protected void playClickSound() {
DC_SoundMaster.playStandardSound(STD_SOUNDS.DIS__OPEN_MENU);
}
};
pos = "pos " + 0 + " " + (y);
add(entryNodeButton, pos);
entryNodeButton.activateMouseListener();
setComponentZOrder(entryNodeButton, i);
i++;
}
}
setComponentZOrder(returnButton, i);
i++;
// setComponentZOrder(toggleButton, i);
// i++;
setComponentZOrder(forwardButton, i);
i++;
setComponentZOrder(backButton, i);
i++;
setComponentZOrder(getCurrentComponent(), i);
}
use of eidolons.system.graphics.PhaseAnimation in project Eidolons by IDemiurge.
the class ArmorMaster method getShieldDamageBlocked.
public int getShieldDamageBlocked(Integer damage, Unit attacked, Unit attacker, DC_ActiveObj action, DC_WeaponObj weapon, DAMAGE_TYPE damage_type) {
if (checkCanShieldBlock(action, attacked)) {
return 0;
}
DC_WeaponObj shield = (DC_WeaponObj) attacked.getRef().getObj(KEYS.OFFHAND);
String message;
boolean spell = action.isSpell();
boolean zone = action.isZone();
boolean offhand = action.isOffhand();
Integer chance = getShieldBlockChance(shield, attacked, attacker, weapon, action, offhand, spell);
if (!zone) {
if (// will be average instead
!simulation) {
if (!RandomWizard.chance(chance)) {
message = StringMaster.getMessagePrefix(true, attacked.getOwner().isMe()) + attacked.getName() + " fails to use " + shield.getName() + " to block " + action.getName() + StringMaster.wrapInParenthesis(chance + "%");
action.getGame().getLogManager().log(LOG.GAME_INFO, message, ENTRY_TYPE.DAMAGE);
return 0;
}
}
}
Integer blockValue = getShieldBlockValue(damage, shield, attacked, attacker, weapon, action, zone);
blockValue = Math.min(blockValue, damage);
if (!simulation) {
action.getRef().setID(KEYS.BLOCK, shield.getId());
int durabilityLost = reduceDurability(blockValue, shield, spell, damage_type, attacker.getActiveWeapon(offhand), damage);
// attacked.getIntParam(PARAMS.SHIELD_MASTERY)) / 100;
if (blockValue <= 0) {
action.getGame().getLogManager().log(LOG.GAME_INFO, shield.getName() + " is ineffective against " + action.getName() + "!", ENTRY_TYPE.DAMAGE);
return 0;
}
DC_SoundMaster.playBlockedSound(attacker, attacked, shield, weapon, blockValue, damage);
// durabilityMod);
if (CoreEngine.isPhaseAnimsOn()) {
PhaseAnimation animation = action.getGame().getAnimationManager().getAnimation(Attack.getAnimationKey(action));
animation.addPhase(new AnimPhase(PHASE_TYPE.REDUCTION_SHIELD, chance, blockValue, durabilityLost, damage, damage_type, shield));
}
message = attacked.getName() + " uses " + shield.getName() + " to block" + "" + " " + blockValue + " out of " + damage + " " + damage_type + " damage from " + // StringMaster.wrapInParenthesis
(action.getName());
action.getGame().getLogManager().log(LOG.GAME_INFO, message, ENTRY_TYPE.DAMAGE);
}
return blockValue;
}
use of eidolons.system.graphics.PhaseAnimation in project Eidolons by IDemiurge.
the class BfMouseListener method checkAnimationClick.
public boolean checkAnimationClick(MouseEvent e) {
point = e.getPoint();
DequeImpl<PhaseAnimation> animations = new DequeImpl<>(gridComp.getGame().getAnimationManager().getAnimations());
animations.addAll(gridComp.getGame().getAnimationManager().getTempAnims());
if (SwingUtilities.isRightMouseButton(e)) {
for (PhaseAnimation anim : animations) {
if (checkToggleTooltip(anim, e)) {
return true;
}
if (anim.contains(e.getPoint())) {
if (e.getClickCount() > 1) {
if (anim.isPaused()) {
anim.resume();
} else {
anim.pause();
}
return true;
}
AnimPhase phase = anim.getPhase();
if (phase != null) {
if (anim.subPhaseClosed()) {
DC_SoundMaster.playStandardSound(STD_SOUNDS.BACK);
return true;
}
}
}
}
}
for (PhaseAnimation anim : animations) {
if (anim.getMouseMap() != null) {
for (Rectangle rect : anim.getMouseMap().keySet()) {
if (rect.contains(point)) {
MouseItem item = anim.getMouseMap().get(rect);
return itemClicked(item, anim);
}
}
}
}
return false;
}
use of eidolons.system.graphics.PhaseAnimation in project Eidolons by IDemiurge.
the class BfMouseListener method checkAnimationPageFlipped.
private boolean checkAnimationPageFlipped(MouseWheelEvent e) {
for (PhaseAnimation anim : gridComp.getGame().getAnimationManager().getAnimations()) {
if (anim.contains(e.getPoint())) {
if (anim.isWheelSupported()) {
if (anim.isManualFlippingSupported()) {
boolean forward = e.getWheelRotation() < 0;
anim.pageFlipped(forward);
return true;
}
}
}
}
return false;
}
Aggregations