public virtual bool RemoveLoan(LoanData data) { LoanDatas.Remove(data); ExpireLoan.Remove(data); CurLoan -= data.Gold; CurLoan = MathUtil.Clamp0(CurLoan); OnRemoveLoan(data); return(true); }
/// <summary> /// 偿还贷款 /// </summary> /// <param name="index"></param> public virtual bool PayLoan(LoanData data) { if (!IsCanPayLoan(data)) { return(false); } CurLoan -= data.Gold; CurLoan = MathUtil.Clamp0(CurLoan); LoanDatas.Remove(data); OnPayLoan(data); ChangeGold(-data.Gold); return(true); }
/// <summary> /// 向银行贷款 /// </summary> public virtual LoanData AddLoan() { if (!IsCanAddLoan()) { return(null); } LoanData tempData = new LoanData(); tempData.Gold = OnceLoanGold; tempData.Interest = Interest; tempData.Date = DateTimeMgr.GetCurYearMonth(); tempData.SetCurCount(LoanPeriod); tempData.SetTotalCount(LoanPeriod); CurLoan += tempData.Gold; LoanDatas.Add(tempData); OnAddLoan(tempData); ChangeGold(tempData.Gold); return(tempData); }
protected virtual void OnRemoveLoan(LoanData data) => Callback_OnLoanChanged?.Invoke();
public bool IsLoanExpire(LoanData data) => data.IsOver();
public bool IsGoldEnough(LoanData data) => CurGold >= data.Gold;
public virtual bool IsCanRemoveLoan(LoanData data) { ACM.Reset(SelfBaseUnit); ACM.Add(new ExCondition(IsLoanExpire(data), "AC_债务没有到期")); return(ACM.IsTrue()); }
public virtual bool IsCanPayLoan(LoanData data) { ACM.Reset(SelfBaseUnit); ACM.Add(new ExCondition(IsGoldEnough(data), "AC_金币不够", data.Gold)); return(ACM.IsTrue()); }