计算损伤通量

时间:2017-12-29 18:57:43

标签: java

所以我正在尝试编写一个程序来模拟损伤计算,而我正在努力编码的一部分是枪的弹药伤害稳定性。

示例:枪对每颗子弹造成x伤害,然而,每颗子弹的伤害稳定性为20%,因此每次射击可能会造成80%的X,因为它的命中造成的伤害为120%。我正在输入攻击,弹药计数和稳定性的值,因为它们都不是硬设定值。现在,我正在试图弄清楚如何使这种通量正常工作。

非常感谢您的协助。

Button runButton = new Button(shell, SWT.NONE);
        runButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                damage = 0;
                damageRaw = 0;
                minuteDamage = 0;
                minuteDamageRaw = 0;
                attack = Integer.valueOf(attackBox.getText());
                cooldown = Float.valueOf(cooldownBox.getText());
                ammo = Integer.valueOf(ammoBox.getText());
                stability = Integer.valueOf(stabilityBox.getText());
                attacksPerMinute = 60 / cooldown;

                damageRaw = attack * ammo;
                minuteDamageRaw = damageRaw * (int)attacksPerMinute;
                rawDamageLabel.setText(damageRaw + " damage " + (int)attacksPerMinute + " times for a total of " + minuteDamageRaw + " damage per minute.");

                float flux = stability/100;
                for (int i = 0; i < attacksPerMinute; ++i) {
                    damage = 0;
                    for (int j = 0; j < ammo; ++j) {
                        damage += 1; //filler
                    }
                    minuteDamage += damage;
                }
                stabilityDamageLabel.setText(damage + " damage " + (int)attacksPerMinute + " times for a total of " + minuteDamage + " damage per minute.");
            }
        });
        runButton.setBounds(349, 10, 75, 25);
        runButton.setText("Open Fire!");

0 个答案:

没有答案