import { _decorator, Button, Component, Label, math, Node } from 'cc';
import { tools } from '../tools';
const { ccclass, property } = _decorator;

@ccclass('test')
export class test extends Component {
    @property(Node) btn_add_50;
    @property(Node) btn_add_500;
    @property(Node) btn_add_5000;
    @property(Node) lab_number;
    private all_num:number = 100;
    protected start(): void {
        this.btn_add_50.on(Node.EventType.TOUCH_END,()=>{
            // this.addCoinNumber(100);
            let origin =  ['2','3','4','5','5','6','6','6','7','20','30']
            let sub = ['3','4','5','6']
            let new_cards = tools.delete_card(origin,sub)
            console.log("new_cards:",new_cards)
        })
        this.btn_add_500.on(Node.EventType.TOUCH_END,()=>{
            this.addCoinNumber(500);
        })
        this.btn_add_5000.on(Node.EventType.TOUCH_END,()=>{
            this.addCoinNumber(5000);
        })
    }

    addCoinNumber(num:number){
        let cur_num = 0;
        let bei = num/100;
        let schedule_num = 0.01/bei; 
        console.log("schedule_num",bei)
        this.schedule(()=>{
            cur_num+=1*bei;
            cur_num = Math.floor(cur_num);
            if(cur_num>=num){
                this.lab_number.getComponent(Label).string = this.all_num+num +"";
                this.unscheduleAllCallbacks()
                return
            }
            this.lab_number.getComponent(Label).string = this.all_num+cur_num +"";
        },schedule_num)
    }
}


