mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew
synced 2026-07-12 00:32:20 +08:00
Change behaviour for item limits
This commit is contained in:
@@ -72,48 +72,46 @@ const LIMIT_COINS: i64 = 2000000000;
|
|||||||
const LIMIT_PRIMOGEMS: i64 = 1000000;
|
const LIMIT_PRIMOGEMS: i64 = 1000000;
|
||||||
|
|
||||||
pub fn give_shop(master_item_id: i64, count: i64, user: &mut JsonValue) -> bool {
|
pub fn give_shop(master_item_id: i64, count: i64, user: &mut JsonValue) -> bool {
|
||||||
let mut has = false;
|
|
||||||
for dataa in user["shop_list"].members_mut() {
|
for dataa in user["shop_list"].members_mut() {
|
||||||
if dataa["master_shop_item_id"].as_i64().unwrap() == master_item_id {
|
if dataa["master_shop_item_id"].as_i64().unwrap() == master_item_id {
|
||||||
has = true;
|
if dataa["count"].as_i64().unwrap() >= LIMIT_ITEMS {
|
||||||
let new_amount = dataa["count"].as_i64().unwrap() + count;
|
|
||||||
if new_amount > LIMIT_ITEMS {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
let mut new_amount = dataa["count"].as_i64().unwrap() + count;
|
||||||
|
if new_amount > LIMIT_ITEMS {
|
||||||
|
new_amount = LIMIT_ITEMS;
|
||||||
|
}
|
||||||
dataa["count"] = new_amount.into();
|
dataa["count"] = new_amount.into();
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !has {
|
user["shop_list"].push(object!{
|
||||||
user["shop_list"].push(object!{
|
master_shop_item_id: master_item_id,
|
||||||
master_shop_item_id: master_item_id,
|
count: count
|
||||||
count: count
|
}).unwrap();
|
||||||
}).unwrap();
|
|
||||||
}
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn give_item(master_item_id: i64, amount: i64, user: &mut JsonValue) -> bool {
|
pub fn give_item(master_item_id: i64, amount: i64, user: &mut JsonValue) -> bool {
|
||||||
let mut has = false;
|
|
||||||
for dataa in user["item_list"].members_mut() {
|
for dataa in user["item_list"].members_mut() {
|
||||||
if dataa["master_item_id"].as_i64().unwrap() == master_item_id {
|
if dataa["master_item_id"].as_i64().unwrap() == master_item_id {
|
||||||
has = true;
|
if dataa["amount"].as_i64().unwrap() >= LIMIT_ITEMS {
|
||||||
let new_amount = dataa["amount"].as_i64().unwrap() + amount;
|
|
||||||
if new_amount > LIMIT_ITEMS {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
let mut new_amount = dataa["amount"].as_i64().unwrap() + amount;
|
||||||
|
if new_amount > LIMIT_ITEMS {
|
||||||
|
new_amount = LIMIT_ITEMS;
|
||||||
|
}
|
||||||
dataa["amount"] = new_amount.into();
|
dataa["amount"] = new_amount.into();
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !has {
|
user["item_list"].push(object!{
|
||||||
user["item_list"].push(object!{
|
id: master_item_id,
|
||||||
id: master_item_id,
|
master_item_id: master_item_id,
|
||||||
master_item_id: master_item_id,
|
amount: amount,
|
||||||
amount: amount,
|
expire_date_time: null
|
||||||
expire_date_time: null
|
}).unwrap();
|
||||||
}).unwrap();
|
|
||||||
}
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,24 +173,23 @@ pub fn give_points(master_item_id: i64, amount: i64, user: &mut JsonValue, missi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut has = false;
|
|
||||||
for data in user["point_list"].members_mut() {
|
for data in user["point_list"].members_mut() {
|
||||||
if data["type"].as_i64().unwrap() == master_item_id {
|
if data["type"].as_i64().unwrap() == master_item_id {
|
||||||
has = true;
|
if data["amount"].as_i64().unwrap() >= LIMIT_COINS {
|
||||||
let new_amount = data["amount"].as_i64().unwrap() + amount;
|
|
||||||
if new_amount > LIMIT_COINS {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
let mut new_amount = data["amount"].as_i64().unwrap() + amount;
|
||||||
|
if new_amount > LIMIT_COINS {
|
||||||
|
new_amount = LIMIT_COINS;
|
||||||
|
}
|
||||||
data["amount"] = new_amount.into();
|
data["amount"] = new_amount.into();
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !has {
|
user["point_list"].push(object!{
|
||||||
user["point_list"].push(object!{
|
type: master_item_id,
|
||||||
type: master_item_id,
|
amount: amount
|
||||||
amount: amount
|
}).unwrap();
|
||||||
}).unwrap();
|
|
||||||
}
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,11 +207,14 @@ pub fn use_itemm(master_item_id: i64, amount: i64, user: &mut JsonValue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn give_primogems(amount: i64, user: &mut JsonValue) -> bool {
|
pub fn give_primogems(amount: i64, user: &mut JsonValue) -> bool {
|
||||||
let new_amount = user["gem"]["free"].as_i64().unwrap() + amount;
|
if user["gem"]["free"].as_i64().unwrap() >= LIMIT_PRIMOGEMS {
|
||||||
if new_amount > LIMIT_PRIMOGEMS {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
let new_amount = user["gem"]["free"].as_i64().unwrap() + amount;
|
||||||
|
if user["gem"]["free"].as_i64().unwrap() > LIMIT_PRIMOGEMS {
|
||||||
|
user["gem"]["free"] = LIMIT_PRIMOGEMS.into();
|
||||||
|
}
|
||||||
|
|
||||||
user["gem"]["free"] = new_amount.into();
|
user["gem"]["free"] = new_amount.into();
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user