炉石传说-鱼人骑士-斩杀计算器-iOS

炉石传说斩杀计算器V1.0 iOS版


本软件为炉石传说游戏开发的斩杀伤害的计算器。目前只提供了鱼人骑士的斩杀计算,更多功能开发中。

软件截图:


首页:

炉石传说-鱼人骑士-斩杀计算器-iOS_第1张图片

鱼人骑士:

炉石传说-鱼人骑士-斩杀计算器-iOS_第2张图片    炉石传说-鱼人骑士-斩杀计算器-iOS_第3张图片

app采用swift语言编写,目前只适配了iPhone5s,代码如下:

//
//  CalculatorViewController.swift
//  HearthStoneKillCalculator
//
//  Created by 何正方 on 16/5/22.
//  Copyright © 2016年 何正方. All rights reserved.
//

import UIKit

class CalculatorViewController: UIViewController {
    
    var numOfFishMen:Int = 0 //鱼人总数
    
    let alertView = UIAlertView()
    
    //蓝腮战士
    var numOfBluegillWarrior:Int = 0
    @IBOutlet weak var numOfBluegillWarriorUI: UILabel!
    @IBAction func bluegillWarriorSub(sender: AnyObject) {
        if (numOfBluegillWarrior > 0) {
            numOfBluegillWarrior -= 1
            numOfFishMen -= 1
            numOfBluegillWarriorUI.text = String(numOfBluegillWarrior)
        } else {
            alertView.message="亲,不能再少了哦!"
            alertView.show()
        }
    }
    @IBAction func bluegillWarriorAdd(sender: AnyObject) {
        if(numOfBluegillWarrior<4){
            numOfBluegillWarrior += 1
            numOfFishMen += 1
            numOfBluegillWarriorUI.text = String(numOfBluegillWarrior)
        } else {
            alertView.message="亲,最多4个哦!"
            alertView.show()
        }
    }
    
    //鱼人领军
    var numOfMurlocWarleader:Int=0
    @IBOutlet weak var numOfMurlocWarleaderUI: UILabel!
    @IBAction func murlocWarleaderSub(sender: AnyObject) {
        if (numOfMurlocWarleader > 0) {
            numOfMurlocWarleader -= 1
            numOfFishMen -= 1
            numOfMurlocWarleaderUI.text = String(numOfMurlocWarleader)
        } else {
            alertView.message="亲,不能再少了哦!"
            alertView.show()
        }
    }
    @IBAction func murlocWarleaderAdd(sender: AnyObject) {
        if(numOfMurlocWarleader<4){
            numOfMurlocWarleader += 1
            numOfFishMen += 1
            numOfMurlocWarleaderUI.text = String(numOfMurlocWarleader)
        } else {
            alertView.message="亲,最多4个哦!"
            alertView.show()
        }
    }
    
    //老瞎眼
    var numOfOldMurkEye:Int=0
    @IBOutlet weak var numOfOldMurkEyeUI: UILabel!
    @IBAction func oldMurkEyeSub(sender: AnyObject) {
        if (numOfOldMurkEye > 0) {
            numOfOldMurkEye -= 1
            numOfFishMen -= 1
            numOfOldMurkEyeUI.text = String(numOfOldMurkEye)
        } else {
            alertView.message="亲,不能再少了哦!"
            alertView.show()
        }
    }
    @IBAction func oldMurkEyeAdd(sender: AnyObject) {
        if(numOfOldMurkEye<2){
            numOfOldMurkEye += 1
            numOfFishMen += 1
            numOfOldMurkEyeUI.text = String(numOfOldMurkEye)
        } else {
            alertView.message="亲,最多2个哦!"
            alertView.show()
        }
    }
    
    //点击计算
    @IBAction func calculator(sender: AnyObject) {
        if(numOfFishMen<8){
            var eachBluegillWarrior:Int
            var kiiOfBluegillWarrior:Int
            var eachOldMurkEye:Int
            var killOfOldMurkEye:Int
            
            if (numOfBluegillWarrior > 0) {
                eachBluegillWarrior = 2 + numOfMurlocWarleader * 2;
            } else {
                eachBluegillWarrior = 0;
            }
            kiiOfBluegillWarrior = eachBluegillWarrior * numOfBluegillWarrior;
            
            if (numOfOldMurkEye > 0) {
                eachOldMurkEye = 2 + numOfMurlocWarleader * 2 + numOfFishMen - 1;
            } else {
                eachOldMurkEye = 0;
            }
            killOfOldMurkEye = (eachOldMurkEye) * numOfOldMurkEye;
            
            sumUI.text="每个蓝腮战士:" + String(eachBluegillWarrior) + " 每个老瞎眼:"
                + String(eachOldMurkEye) + " 总:" + String(kiiOfBluegillWarrior + killOfOldMurkEye)
        }else{
            var fishmen:[String] = [String]();
            
            for _ in 0...numOfBluegillWarrior-1 {
                fishmen.append("BluegillWarrior");
            }
            for _ in 0...numOfMurlocWarleader-1 {
                fishmen.append("MurlocWarleader");
            }
            for _ in 0...numOfOldMurkEye-1 {
                fishmen.append("OldMurkEye");
            }
            
            var sevenNum:[Int] = generate7RandomNum();
            var reBirthBluegillWarrior = 0;
            var reBirthMurlocWarleader = 0;
            var reBirthOldMurkEye = 0;
            for i in 0...sevenNum.count-1 {
                let fishName:String = fishmen[sevenNum[i]];
                if ("BluegillWarrior"==fishName) {
                    reBirthBluegillWarrior += 1;
                } else if ("MurlocWarleader"==fishName) {
                    reBirthMurlocWarleader += 1;
                } else if ("OldMurkEye"==fishName) {
                    reBirthOldMurkEye += 1;
                }
            }
            var eachBluegillWarrior:Int;
            var kiiOfBluegillWarrior:Int;
            var eachOldMurkEye:Int;
            var killOfOldMurkEye:Int;
            
            if(reBirthBluegillWarrior>0){
                eachBluegillWarrior = 2 + reBirthMurlocWarleader * 2;
            }else{
                eachBluegillWarrior=0
            }
            kiiOfBluegillWarrior = eachBluegillWarrior * reBirthBluegillWarrior;
            if(reBirthOldMurkEye>0){
                eachOldMurkEye = 2 + reBirthMurlocWarleader * 2 + 7 - 1;
            }else{
                eachOldMurkEye=0
            }
            killOfOldMurkEye = (eachOldMurkEye) * reBirthOldMurkEye;
            
            sumUI.text="你可能召唤出" + String(reBirthBluegillWarrior) + "个蓝腮," +
                String(reBirthMurlocWarleader) + "个领军," + String(reBirthOldMurkEye) +
                "个老瞎眼。" + "每个蓝腮战士:" + String(eachBluegillWarrior) + " 每个老瞎眼:" +
                String(eachOldMurkEye) + " 总:" + String(kiiOfBluegillWarrior + killOfOldMurkEye)
        }
    }
    
    //斩杀值显示框
    @IBOutlet weak var sumUI: UITextView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        alertView.title="提示"
        alertView.delegate=nil
        alertView.addButtonWithTitle("确定")
        // Do any additional setup after loading the view.
    }
    
    func generate7RandomNum() -> [Int]{
        let n:UInt32 = UInt32(numOfFishMen)
        var seven:[Int] = [Int](count:7, repeatedValue:0)
        var bool:[Bool] = [Bool](count:numOfFishMen, repeatedValue:false)
        var randInt:Int
        for i in 0...6 {
            repeat{
                randInt=Int(arc4random_uniform(n))
            }while (bool[randInt])
            bool[randInt]=true
            seven[i]=randInt
        }
        return seven
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

你可能感兴趣的:(炉石传说-鱼人骑士-斩杀计算器-iOS)