Compare commits

...

5 commits

Author SHA1 Message Date
YYHEggEgg
5982523c98 command: player kick [uid] [reason] 2024-07-31 00:41:20 +08:00
YYHEggEgg
28a3c8d154 Gacha Model bugfix: post_configure on creating 2024-07-31 00:37:13 +08:00
YYHEggEgg
2041d8dd03 Gacha impl 2024-07-30 16:53:54 +08:00
YYHEggEgg
d67db9f57a Proto (Gacha related) 2024-07-30 16:52:35 +08:00
YYHEggEgg
dcb0e49345 Implement static config gacha needed 2024-07-30 10:41:18 +08:00
19 changed files with 1156 additions and 106 deletions

View file

View file

@ -18,3 +18,5 @@ tracing.workspace = true
# Internal
proto.workspace = true
jsonc-parser = { version = "0.23.0", features = ["serde"] }
chrono = { version = "0.4.38", features = ["serde"] }

View file

@ -0,0 +1,229 @@
use std::collections::{HashMap, HashSet};
use chrono::{prelude::Local, DateTime};
use serde::Deserialize;
use tracing;
#[derive(Debug, Default, Deserialize)]
pub struct ExtraItemsPolicy {
pub id: u32,
pub count: u32,
#[serde(default)]
pub apply_on_owned_count: u32,
}
#[derive(Debug, Default, Deserialize)]
pub struct ProbabilityPoint {
pub start_pity: u32,
pub start_chance_percent: f64,
#[serde(default)]
pub increment_percent: f64,
}
#[derive(Debug, Default, Deserialize)]
pub struct ProbabilityModel {
#[serde(default)]
pub clear_status_on_higher_rarity_pulled: bool,
pub points: Vec<ProbabilityPoint>,
// This value is for display only, so it's set when
// the maximum guarantee is not equal to the
// automatically calculated value (commonly, less than).
#[serde(default)]
pub maximum_guarantee_pity: u32,
#[serde(skip_deserializing)]
probability_percents: Vec<f64>,
}
impl ProbabilityModel {
fn get_maximum_guarantee(&self) -> u32 {
self.probability_percents.len() as u32 - 1
}
pub fn post_configure(&mut self, tag: &String) {
self.points.sort_by_key(|point| point.start_pity);
let mut probability_percents: Vec<f64> = vec![0.0];
for (i, point) in self.points.iter().enumerate() {
if i > 0 {
let last_point = &self.points[i - 1];
let last_stop_percent = last_point.start_chance_percent
+ last_point.increment_percent
* (point.start_pity - last_point.start_pity) as f64;
if last_stop_percent > point.start_chance_percent {
tracing::warn!("Gacha - ProbabilityModel '{tag}': The start chance of '{point:?}' is less than the value inherited from the previous point.");
}
}
let mut max_pity = 2000;
if i < self.points.len() - 1 {
let next_point = &self.points[i + 1];
max_pity = next_point.start_pity - 1;
let max_probability = point.start_chance_percent
+ point.increment_percent
* (next_point.start_pity - 1 - point.start_pity) as f64;
assert!(max_probability < 100.0, "Gacha - ProbabilityModel '{tag}': Probability already reached 100% in '{point:?}' (though points with higher pity left)");
}
let mut pity = point.start_pity;
let mut percent = point.start_chance_percent;
while pity <= max_pity {
if max_pity >= 2000 && percent >= 100.0 {
probability_percents.push(100.0);
break;
}
probability_percents.push(percent);
percent += point.increment_percent;
pity += 1;
}
assert!(pity <= 2000, "Gacha - ProbabilityModel '{tag}' (point {i}): Haven't reached 100% guarantee probability at Pity 2001. The current probability is {percent}%. Crazy.");
}
self.probability_percents = probability_percents;
if self.maximum_guarantee_pity <= 0 {
self.maximum_guarantee_pity = self.get_maximum_guarantee();
}
}
pub fn get_chance_percent(&self, pity: &u32) -> f64 {
// The vec length is 1 bigger than the maximum pity (1-based)
let guarantee_pity = self.probability_percents.len() - 1;
let idx = *pity as usize;
if idx > guarantee_pity {
return self.probability_percents[guarantee_pity];
}
self.probability_percents[idx]
}
}
#[allow(dead_code)]
#[derive(Debug, Default, Deserialize)]
pub struct CategoryGuaranteePolicy {
pub included_category_tags: HashSet<String>,
pub trigger_on_failure_times: u32,
pub clear_status_on_target_changed: bool,
pub chooseable: bool,
}
#[derive(Debug, Default, Deserialize)]
pub struct TenPullDiscount {
pub use_limit: u32,
pub discounted_prize: u32,
}
#[derive(Debug, Default, Deserialize)]
pub struct AdvancedGuarantee {
pub use_limit: u32,
pub rarity: u32,
pub guarantee_pity: u32,
}
#[derive(Debug, Default, Deserialize)]
pub struct MustGainItem {
pub use_limit: u32,
pub rarity: u32,
pub category_tag: String,
}
#[derive(Debug, Default, Deserialize)]
pub struct DiscountPolicyCollection {
pub ten_pull_discount_map: HashMap<String, TenPullDiscount>,
pub must_gain_item_map: HashMap<String, MustGainItem>,
pub advanced_guarantee_map: HashMap<String, AdvancedGuarantee>,
}
impl DiscountPolicyCollection {
pub fn post_configure(&mut self) {
for (tag, ten_pull_discount) in self.ten_pull_discount_map.iter() {
let discounted_prize = ten_pull_discount.discounted_prize;
assert!(discounted_prize < 10, "Gacha - DiscountPolicy '{tag}': ten_pull_discount's value should be smaller than 10 (read {discounted_prize}).");
}
}
}
#[derive(Debug, Default, Deserialize)]
pub struct GachaCategoryInfo {
#[serde(default)]
pub is_promotional_items: bool,
pub item_ids: Vec<u32>,
pub category_weight: u32,
}
#[derive(Debug, Default, Deserialize)]
pub struct GachaAvailableItemsInfo {
pub rarity: u32,
#[serde(default)]
pub extra_items_policy_tags: Vec<String>,
pub categories: HashMap<String, GachaCategoryInfo>,
pub probability_model_tag: String,
#[serde(default)]
pub category_guarantee_policy_tags: Vec<String>,
}
#[allow(dead_code)]
#[derive(Debug, Default, Deserialize)]
pub struct CharacterGachaPool {
pub gacha_schedule_id: u32,
pub gacha_parent_schedule_id: u32,
pub comment: String,
pub gacha_type: u32,
pub cost_item_id: u32,
pub start_time: DateTime<Local>,
pub end_time: DateTime<Local>,
#[serde(default)]
pub discount_policy_tags: Vec<String>,
pub sharing_guarantee_info_category: String,
pub gacha_items: Vec<GachaAvailableItemsInfo>,
}
impl CharacterGachaPool {
pub fn is_still_open(&self, now: &DateTime<Local>) -> bool {
self.start_time <= *now && *now <= self.end_time
}
pub fn post_configure(&mut self, probability_model_map: &HashMap<String, ProbabilityModel>) {
self.gacha_items
.sort_by_key(|item_list| u32::MAX - item_list.rarity);
for items_info in self.gacha_items.iter_mut() {
assert!(probability_model_map.contains_key(&items_info.probability_model_tag), "Gacha - CharacterGachaPool '{}': Specified ProbabilityModel tag '{}' that does not exist.", self.gacha_schedule_id, items_info.probability_model_tag);
}
}
}
#[derive(Debug, Default, Deserialize)]
pub struct GachaCommonProperties {
pub up_item_category_tag: String,
pub s_item_rarity: u32,
pub a_item_rarity: u32,
// TODO: PostConfigure check
pub ten_pull_discount_tag: String,
pub newcomer_advanced_s_tag: String,
}
#[derive(Debug, Default, Deserialize)]
pub struct GachaConfiguration {
pub character_gacha_pool_list: Vec<CharacterGachaPool>,
pub probability_model_map: HashMap<String, ProbabilityModel>,
pub category_guarantee_policy_map: HashMap<String, CategoryGuaranteePolicy>,
pub extra_items_policy_map: HashMap<String, ExtraItemsPolicy>,
pub discount_policies: DiscountPolicyCollection,
pub common_properties: GachaCommonProperties,
}
impl GachaConfiguration {
pub fn post_configure(&mut self) {
assert!(
self.category_guarantee_policy_map
.contains_key(&self.common_properties.up_item_category_tag),
"The UP category should be valid in policy map."
);
for (tag, policy) in self.probability_model_map.iter_mut() {
policy.post_configure(&tag);
}
self.discount_policies.post_configure();
for character_pool in self.character_gacha_pool_list.iter_mut() {
character_pool.post_configure(&self.probability_model_map);
}
}
}

45
nap_data/src/gacha/mod.rs Normal file
View file

@ -0,0 +1,45 @@
use std::sync::OnceLock;
use gacha_config::GachaConfiguration;
use jsonc_parser::{parse_to_serde_value, ParseOptions};
use serde::Deserialize;
use crate::{action::ActionConfig, DataLoadError};
pub mod gacha_config;
const GACHA_CONFIG_NAME: &str = "gacha.jsonc";
static GACHACONF: OnceLock<GachaConfiguration> = OnceLock::new();
#[derive(Deserialize, Debug)]
pub struct EventGraphConfig {
pub event_id: u32,
pub actions: Vec<ActionConfig>,
}
pub(crate) fn load_gacha_config(path: &str) -> Result<(), DataLoadError> {
let jsonc_data = std::fs::read_to_string(format!("{path}/{GACHA_CONFIG_NAME}"))
.map_err(|err| DataLoadError::IoError(err))?;
let json_value = parse_to_serde_value(
&jsonc_data,
&ParseOptions {
allow_comments: true,
allow_loose_object_property_names: false,
allow_trailing_commas: true,
},
)
.map_err(|err| DataLoadError::JsoncParseError(err))?
.unwrap();
let mut result = serde_json::from_value::<GachaConfiguration>(json_value)
.map_err(|err| DataLoadError::FromJsonError(String::from("GachaConfiguration"), err))?;
result.post_configure();
GACHACONF.set(result).unwrap();
Ok(())
}
pub fn global_gacha_config() -> &'static GachaConfiguration {
GACHACONF.get().unwrap()
}

View file

@ -1,9 +1,11 @@
pub mod action;
pub mod event;
pub mod gacha;
pub mod tables;
use std::{collections::HashMap, sync::OnceLock};
use jsonc_parser::errors::ParseError;
use serde::{Deserialize, Serialize};
use thiserror::Error;
@ -12,6 +14,7 @@ pub struct AssetsConfig {
pub filecfg_path: String,
pub event_config_path: String,
pub usm_keys_path: String,
pub gacha_config_path: String,
}
#[derive(Error, Debug)]
@ -20,6 +23,8 @@ pub enum DataLoadError {
IoError(#[from] std::io::Error),
#[error("from_json failed for type {0}, error: {1}")]
FromJsonError(String, serde_json::Error),
#[error("jsonc_parser parse as json error: {0}")]
JsoncParseError(#[from] ParseError),
}
static USM_KEY_MAP: OnceLock<HashMap<u32, u64>> = OnceLock::new();
@ -31,6 +36,7 @@ pub fn init_data(config: &AssetsConfig) -> Result<(), DataLoadError> {
tracing::warn!("failed to load USM keys, in-game cutscenes will not work! Reason: {err}");
USM_KEY_MAP.set(HashMap::new()).unwrap();
}
gacha::load_gacha_config(&config.gacha_config_path)?;
Ok(())
}

View file

@ -41,3 +41,4 @@ tracing-bunyan-formatter.workspace = true
common.workspace = true
data.workspace = true
proto.workspace = true
chrono = { version = "0.4.38", features = ["serde"] }

View file

@ -87,5 +87,6 @@ impl CommandManager {
player::procedure "[player_uid] [procedure_id]" "changes current beginner procedure id, parameter -1 can be used for skipping it";
avatar::add "[player_uid] [avatar_id]" "gives avatar with specified id to player";
item::add_weapon "[player_uid] [weapon_id]" "gives weapon with specified id to player";
player::kick "[player_uid] [reason]" "kick the specified player (reason is optional)";
}
}

View file

@ -1,5 +1,5 @@
use data::tables::{AvatarBaseID, ProcedureConfigID};
use proto::PlayerSyncScNotify;
use proto::{DisconnectReason, DisconnectScNotify, PlayerSyncScNotify};
use crate::ServerState;
@ -126,3 +126,44 @@ pub async fn procedure(
"successfully changed procedure_id to {procedure_id:?}"
))
}
pub async fn kick(
args: ArgSlice<'_>,
state: &ServerState,
) -> Result<String, Box<dyn std::error::Error>> {
const USAGE: &str = "Usage: player kick [player_uid]";
if args.len() > 2 {
return Ok(USAGE.to_string());
}
let uid = args[0].parse::<u32>()?;
let reason = match args.get(1) {
Some(arg) => match arg.parse::<i32>() {
Ok(val) => val,
Err(_err) => 1,
},
None => 1,
};
let reason_str = match DisconnectReason::try_from(reason) {
Ok(converted_enum) => converted_enum.as_str_name().to_owned(),
Err(_err) => reason.to_string(),
};
let Some(player_lock) = state.player_mgr.get_player(uid).await else {
return Ok(String::from("player not found"));
};
let session_id = player_lock.lock().await.current_session_id();
if let Some(session) = session_id.map(|id| state.session_mgr.get(id)).flatten() {
session
.notify(DisconnectScNotify { reason: reason })
.await?;
tokio::time::sleep(tokio::time::Duration::from_millis(50)).await;
session.shutdown().await?;
Ok(format!("kicked player, uid: {uid}, reason: {reason_str}"))
} else {
Ok(format!("player uid: {uid} is not online yet."))
}
}

View file

@ -21,6 +21,7 @@ impl Default for NapGSConfig {
filecfg_path: String::from("assets/FileCfg"),
event_config_path: String::from("assets/EventConfig"),
usm_keys_path: String::from("assets/VideoUSMEncKeys.json"),
gacha_config_path: String::from("assets/GachaConfig"),
},
}
}

View file

@ -1,13 +1,234 @@
use data::gacha::{gacha_config::*, global_gacha_config};
use proto::*;
use super::*;
use chrono::{DateTime, Local};
pub async fn on_get_gacha_data(
_session: &NetSession,
_player: &mut Player,
req: GetGachaDataCsReq,
) -> NetResult<GetGachaDataScRsp> {
if req.gacha_type != 3 {
// tracing::info!("non-supported gacha type {}", body.gacha_type);
Ok(GetGachaDataScRsp {
retcode: Retcode::RetSucc.into(),
gacha_type: req.gacha_type,
gacha_data: Some(GachaData::default()),
})
} else {
// tracing::info!("construct gacha info");
Ok(GetGachaDataScRsp {
retcode: Retcode::RetSucc.into(),
gacha_type: req.gacha_type,
gacha_data: Some(generate_all_gacha_info(_player)),
})
}
}
pub async fn on_do_gacha(
_session: &NetSession,
_player: &mut Player,
req: DoGachaCsReq,
) -> NetResult<DoGachaScRsp> {
let gachaconf = global_gacha_config();
let gacha_model = &mut _player.gacha_model;
let pull_time = Local::now();
let target_pool = get_gacha_pool(
&gachaconf.character_gacha_pool_list,
&req.gacha_parent_schedule_id,
&pull_time,
);
if let None = target_pool {
return Ok(DoGachaScRsp {
retcode: Retcode::RetSucc.into(),
..Default::default()
});
};
let target_pool = target_pool.unwrap();
// TODO: Validate cost_item_count
// tracing::info!("cost_item_count: {}", body.cost_item_count);
let mut pull_count = if req.cost_item_count > 1 { 10 } else { 1 };
if pull_count == 10 {
let discount_tag = &gachaconf.common_properties.ten_pull_discount_tag;
if target_pool.discount_policy_tags.contains(&discount_tag) {
let gacha_bin = &mut gacha_model.gacha_bin;
let status_bin = gacha_bin
.gacha_status_map
.get_mut(&target_pool.sharing_guarantee_info_category)
.unwrap();
let discount_policy = gachaconf
.discount_policies
.ten_pull_discount_map
.get(discount_tag)
.unwrap();
let usage = status_bin.discount_usage_map.get_mut(discount_tag).unwrap();
if *usage < discount_policy.use_limit {
*usage += 1;
}
}
}
let mut gain_item_list: Vec<GainItemInfo> = vec![];
while pull_count > 0 {
let pull_result = gacha_model.perform_pull_pool(&pull_time, target_pool);
let extra_item_bin = pull_result.extra_item_bin.unwrap();
gain_item_list.push(GainItemInfo {
item_id: pull_result.obtained_item_id,
extra_item_id: extra_item_bin.extra_item_id,
extra_item_count: extra_item_bin.extra_item_count,
num: 1,
..GainItemInfo::default()
});
pull_count -= 1;
}
Ok(DoGachaScRsp {
retcode: Retcode::RetSucc.into(),
gain_item_list,
gacha_data: Some(generate_all_gacha_info(_player)),
cost_item_count: req.cost_item_count,
})
}
fn generate_gacha_info_from_pool(
gacha_bin: &GachaModelBin,
target_pool: &CharacterGachaPool,
common_properties: &GachaCommonProperties,
) -> Gacha {
let gachaconf = data::gacha::global_gacha_config();
let sharing_guarantee_category_tag = &target_pool.sharing_guarantee_info_category;
let status_bin = gacha_bin
.gacha_status_map
.get(sharing_guarantee_category_tag)
.unwrap();
let pity_s = status_bin
.rarity_status_map
.get(&common_properties.s_item_rarity)
.unwrap()
.pity;
let pity_a = status_bin
.rarity_status_map
.get(&common_properties.a_item_rarity)
.unwrap()
.pity;
let mut up_s_item_list: Vec<u32> = vec![];
let mut up_a_item_list: Vec<u32> = vec![];
let mut s_guarantee: u32 = 0;
let mut a_guarantee: u32 = 0;
for rarity_items in target_pool.gacha_items.iter() {
for category in rarity_items.categories.values() {
let probability_model = gachaconf
.probability_model_map
.get(&rarity_items.probability_model_tag)
.unwrap();
if rarity_items.rarity == common_properties.s_item_rarity {
if category.is_promotional_items {
up_s_item_list = category.item_ids.clone();
}
s_guarantee = probability_model.maximum_guarantee_pity - pity_s + 1;
}
if rarity_items.rarity == common_properties.a_item_rarity {
if category.is_promotional_items {
up_a_item_list = category.item_ids.clone();
}
a_guarantee = probability_model.maximum_guarantee_pity - pity_a + 1;
}
}
}
let mut discount_ten_roll_prize: u32 = 0;
let mut discount_avaliable_num: u32 = 0;
let mut advanced_s_guarantee: u32 = 0;
for discount_policy_tag in target_pool.discount_policy_tags.iter() {
if common_properties.newcomer_advanced_s_tag == *discount_policy_tag {
let policy = gachaconf
.discount_policies
.advanced_guarantee_map
.get(discount_policy_tag)
.unwrap();
if status_bin
.discount_usage_map
.get(discount_policy_tag)
.unwrap()
< &policy.use_limit
{
advanced_s_guarantee = policy.guarantee_pity - pity_s + 1;
}
} else if common_properties.ten_pull_discount_tag == *discount_policy_tag {
let policy = gachaconf
.discount_policies
.ten_pull_discount_map
.get(discount_policy_tag)
.unwrap();
let discount_usage = status_bin
.discount_usage_map
.get(discount_policy_tag)
.unwrap();
if discount_usage < &policy.use_limit {
discount_ten_roll_prize = policy.discounted_prize;
discount_avaliable_num = policy.use_limit - discount_usage;
}
}
}
let need_item_info_list: Vec<NeedItemInfo> = vec![NeedItemInfo {
need_item_id: target_pool.cost_item_id,
need_item_count: 1,
}];
Gacha {
gacha_schedule_id: target_pool.gacha_schedule_id,
gacha_parent_schedule_id: target_pool.gacha_parent_schedule_id,
gacha_type: target_pool.gacha_type,
start_timestamp: target_pool.start_time.timestamp(),
end_timestamp: target_pool.end_time.timestamp(),
discount_avaliable_num,
discount_ten_roll_prize,
up_s_item_list,
up_a_item_list,
advanced_s_guarantee,
s_guarantee,
a_guarantee,
need_item_info_list,
// iehkehofjop: target_pool.gacha_parent_schedule_id,
// eggcehlgkii: 223,
// ijoahiepmfo: 101,
..Gacha::default()
}
}
fn generate_all_gacha_info(_player: &Player) -> GachaData {
let gachaconf = global_gacha_config();
let gacha_bin = &_player.gacha_model.gacha_bin;
let mut gacha_list: Vec<Gacha> = vec![];
for target_pool in gachaconf.character_gacha_pool_list.iter() {
gacha_list.push(generate_gacha_info_from_pool(
&gacha_bin,
target_pool,
&gachaconf.common_properties,
));
}
GachaData {
random_number: 0,
gacha_pool: Some(GachaPool { gacha_list }),
..GachaData::default()
}
}
fn get_gacha_pool<'conf>(
character_gacha_pool_list: &'conf Vec<CharacterGachaPool>,
gacha_parent_schedule_id: &u32,
pull_time: &DateTime<Local>,
) -> Option<&'conf CharacterGachaPool> {
for target_pool in character_gacha_pool_list.iter() {
if &target_pool.gacha_parent_schedule_id == gacha_parent_schedule_id
&& target_pool.is_still_open(pull_time)
{
return Some(target_pool);
}
}
None
}

View file

@ -119,6 +119,7 @@ req_handlers! {
event_graph::RunEventGraph;
quest::BeginArchiveBattleQuest;
quest::FinishArchiveQuest;
gacha::DoGacha;
}
notify_handlers! {

View file

@ -0,0 +1,398 @@
use data::gacha;
use data::gacha::gacha_config::*;
use proto::*;
use chrono::{DateTime, Local};
use rand::{thread_rng, Rng};
use std::collections::{HashMap, HashSet};
use std::hash::{BuildHasher, Hash};
pub struct GachaModel {
pub gacha_bin: GachaModelBin,
}
impl Default for GachaModel {
fn default() -> GachaModel {
let result = GachaModel {
gacha_bin: GachaModelBin::default(),
};
result.post_deserialize()
}
}
impl GachaModel {
pub fn from_bin(gacha_bin: GachaModelBin) -> Self {
let result = Self { gacha_bin };
result.post_deserialize()
}
pub fn to_bin(&self) -> GachaModelBin {
self.gacha_bin.clone()
}
pub fn post_deserialize(mut self) -> GachaModel {
let gachaconf = gacha::global_gacha_config();
for gacha_pool in gachaconf.character_gacha_pool_list.iter() {
let gacha_comp_bin = &mut self.gacha_bin;
let mut gacha_status_map = &mut gacha_comp_bin.gacha_status_map;
let status_bin = get_or_add(
&mut gacha_status_map,
&gacha_pool.sharing_guarantee_info_category,
);
for rarity_items in gacha_pool.gacha_items.iter() {
let progress_bin =
get_or_add(&mut status_bin.rarity_status_map, &rarity_items.rarity);
if progress_bin.pity <= 0 {
progress_bin.pity = 1;
}
for category_guarantee_policy_tag in
rarity_items.category_guarantee_policy_tags.iter()
{
get_or_add(
&mut progress_bin.categories_progress_map,
&category_guarantee_policy_tag,
);
}
}
for discount_policy_tag in gacha_pool.discount_policy_tags.iter() {
get_or_add(&mut status_bin.discount_usage_map, &discount_policy_tag);
}
}
self
}
pub fn perform_pull_pool<'bin, 'conf>(
&'bin mut self,
pull_time: &DateTime<Local>,
target_pool: &'conf CharacterGachaPool,
) -> GachaRecordBin {
let mut gacha_bin = &mut self.gacha_bin;
let (rarity_items, progress_bin, status_bin, probability_model) =
determine_rarity(&gacha_bin, target_pool);
let (category_tag, category) = determine_category(rarity_items, progress_bin, target_pool);
let result =
determine_gacha_result(pull_time, category, target_pool, status_bin, rarity_items);
update_pity(&mut gacha_bin, rarity_items, probability_model, target_pool);
update_category_guarantee_info(&mut gacha_bin, rarity_items, &category_tag, target_pool);
update_discount(&mut gacha_bin, target_pool, &category_tag, rarity_items);
result
}
}
fn get_or_add<'a, K: Eq + PartialEq + Hash + Clone, V: Default, S: BuildHasher>(
map: &'a mut HashMap<K, V, S>,
key: &K,
) -> &'a mut V {
if !map.contains_key(key) {
map.insert(key.clone(), V::default());
}
map.get_mut(key).unwrap()
}
fn rand_rarity<'bin, 'conf>(
target_pool: &'conf CharacterGachaPool,
status_bin: &'bin GachaStatusBin,
) -> (
&'conf GachaAvailableItemsInfo,
&'bin GachaProgressBin,
&'conf ProbabilityModel,
) {
let gachaconf = gacha::global_gacha_config();
let mut rng = thread_rng();
let rarity_status_map = &status_bin.rarity_status_map;
// gacha_items is already sorted by rarity descendingly in its post_configure.
for rarity_items in target_pool.gacha_items.iter() {
// Surely any judgement should be made on the current pity.
let progress_bin = rarity_status_map.get(&rarity_items.rarity).unwrap();
let pity = progress_bin.pity;
let probability_model = gachaconf
.probability_model_map
.get(&rarity_items.probability_model_tag)
.unwrap();
if rng.gen_range(0.0..100.0) <= probability_model.get_chance_percent(&pity) {
return (rarity_items, progress_bin, probability_model);
}
}
panic!("The user failed to get any items.");
}
fn determine_rarity<'bin, 'conf>(
gacha_bin: &'bin GachaModelBin,
target_pool: &'conf CharacterGachaPool,
) -> (
&'conf GachaAvailableItemsInfo,
&'bin GachaProgressBin,
&'bin GachaStatusBin,
&'conf ProbabilityModel,
) {
let gachaconf = gacha::global_gacha_config();
let status_bin = gacha_bin
.gacha_status_map
.get(&target_pool.sharing_guarantee_info_category)
.expect(&format!(
"post_deserialize forgot StatusBin/sharing_guarantee_info_category: {}",
target_pool.sharing_guarantee_info_category
));
let (mut rarity_items, mut progress_bin, mut probability_model) =
rand_rarity(target_pool, &status_bin);
// We should take AdvancedGuarantee discount into consideration.
for discount_tag in target_pool.discount_policy_tags.iter() {
if let Some(discount) = gachaconf
.discount_policies
.advanced_guarantee_map
.get(discount_tag)
{
if discount.rarity <= rarity_items.rarity {
continue;
}
if status_bin
.discount_usage_map
.get(discount_tag)
.expect(&format!(
"post_deserialize forgot StatusBin/discount_usage_map: {}",
discount_tag
))
>= &discount.use_limit
{
continue;
}
let higher_progress_bin =
status_bin
.rarity_status_map
.get(&discount.rarity)
.expect(&format!(
"post_deserialize forgot StatusBin/rarity_status_map: {}",
&discount.rarity
));
if higher_progress_bin.pity >= discount.guarantee_pity {
let mut found_rarity_items = false;
for gacha_items in target_pool.gacha_items.iter() {
if gacha_items.rarity == discount.rarity {
rarity_items = gacha_items;
probability_model = gachaconf
.probability_model_map
.get(&gacha_items.probability_model_tag)
.unwrap();
found_rarity_items = true;
break;
}
}
assert!(found_rarity_items, "Handle AdvancedGuarantee Discount ({discount_tag}) error: The target rarity does not exist in this pool.");
progress_bin = higher_progress_bin;
}
}
}
(rarity_items, progress_bin, status_bin, probability_model)
}
fn determine_category<'bin, 'conf>(
rarity_items: &'conf GachaAvailableItemsInfo,
progress_bin: &'bin GachaProgressBin,
target_pool: &'conf CharacterGachaPool,
) -> (String, &'conf GachaCategoryInfo) {
let gachaconf = gacha::global_gacha_config();
let mut category_tag_inited = false;
let mut category_tag_result: HashSet<String> = HashSet::new();
// First of all, if there's a chooseable category and
// it's can be triggered, then we MUST give that
// category's item.
// TODO: Only Genshin can do
// Then we should take a look at MustGainItem.
if !category_tag_inited {
for discount_policy_tag in target_pool.discount_policy_tags.iter() {
if let Some(discount) = gachaconf
.discount_policies
.must_gain_item_map
.get(discount_policy_tag)
{
if discount.rarity != rarity_items.rarity {
continue;
}
category_tag_result.insert(discount.category_tag.clone());
category_tag_inited = true;
}
}
}
// Otherwise, just select as normal.
if !category_tag_inited {
for tag in rarity_items.categories.keys() {
category_tag_result.insert(tag.clone());
}
for guarantee_policy_tag in rarity_items.category_guarantee_policy_tags.iter() {
let category_guarantee_policy = gachaconf
.category_guarantee_policy_map
.get(guarantee_policy_tag)
.unwrap();
let failure_times = progress_bin.categories_progress_map
.get(guarantee_policy_tag)
.expect(&format!("post_deserialize forgot StatusBin/rarity_status_map[{}]/categories_progress_map: {}", &rarity_items.rarity, guarantee_policy_tag));
if failure_times >= &category_guarantee_policy.trigger_on_failure_times {
category_tag_result = category_tag_result
.intersection(&category_guarantee_policy.included_category_tags)
.cloned()
.collect();
}
}
// category_tag_inited = true;
}
let mut categories: Vec<(String, &GachaCategoryInfo)> = vec![];
let mut weight_sum = 0;
for result_tag in category_tag_result {
let category = rarity_items.categories.get(&result_tag).unwrap();
categories.push((result_tag, category));
weight_sum += category.category_weight;
}
let randomnum = rand::thread_rng().gen_range(0..weight_sum);
let mut enumerated_ranges_end = 0;
for category in categories.into_iter() {
if randomnum <= enumerated_ranges_end + category.1.category_weight {
return (category.0, category.1);
}
enumerated_ranges_end += category.1.category_weight;
}
panic!("No category is chosen.");
}
fn determine_gacha_result<'bin, 'conf>(
pull_time: &DateTime<Local>,
category: &'conf GachaCategoryInfo,
target_pool: &'conf CharacterGachaPool,
status_bin: &'bin GachaStatusBin,
rarity_items: &'conf GachaAvailableItemsInfo,
) -> GachaRecordBin {
let gachaconf = gacha::global_gacha_config();
let item_pool_len = category.item_ids.len() as u32;
let item_id = category
.item_ids
.get(rand::thread_rng().gen_range(0..item_pool_len) as usize)
.unwrap();
let mut extra_item_id: u32 = 0;
let mut extra_item_count: u32 = 0;
for extra_items_policy_tag in rarity_items.extra_items_policy_tags.iter() {
let extra_items_policy = gachaconf
.extra_items_policy_map
.get(extra_items_policy_tag)
.unwrap();
// TODO: apply_on_owned_count in a context with bag
if extra_items_policy.apply_on_owned_count == 0 {
extra_item_id = extra_items_policy.id;
extra_item_count = extra_items_policy.count;
}
}
let extra_item_bin = GachaExtraItemBin {
extra_item_id,
extra_item_count,
currently_gained: 0,
};
GachaRecordBin {
pull_timestamp: pull_time.timestamp(),
obtained_item_id: item_id.clone(),
gacha_id: target_pool.gacha_schedule_id.clone(),
progress_map: status_bin.rarity_status_map.clone(),
extra_item_bin: Some(extra_item_bin),
}
}
fn update_pity<'bin, 'conf>(
gacha_bin: &'bin mut GachaModelBin,
rarity_items: &'conf GachaAvailableItemsInfo,
probability_model: &'conf ProbabilityModel,
target_pool: &'conf CharacterGachaPool,
) {
let status_bin = gacha_bin
.gacha_status_map
.get_mut(&target_pool.sharing_guarantee_info_category)
.unwrap();
for (rarity, rarity_status) in status_bin.rarity_status_map.iter_mut() {
if (rarity == &rarity_items.rarity)
|| (probability_model.clear_status_on_higher_rarity_pulled
&& rarity < &rarity_items.rarity)
{
rarity_status.pity = 1;
} else {
rarity_status.pity += 1;
}
}
}
fn update_category_guarantee_info<'bin, 'conf>(
gacha_bin: &'bin mut GachaModelBin,
rarity_items: &'conf GachaAvailableItemsInfo,
category_tag: &String,
target_pool: &'conf CharacterGachaPool,
) {
let gachaconf = gacha::global_gacha_config();
let status_bin = gacha_bin
.gacha_status_map
.get_mut(&target_pool.sharing_guarantee_info_category)
.unwrap();
let progress_bin = status_bin
.rarity_status_map
.get_mut(&rarity_items.rarity)
.unwrap();
for policy_tag in rarity_items.category_guarantee_policy_tags.iter() {
let policy = gachaconf
.category_guarantee_policy_map
.get(policy_tag)
.unwrap();
// TODO: Chooseable guarantee not implemented
let prev_failure = progress_bin
.categories_progress_map
.get_mut(policy_tag)
.expect(&format!(
"post_deserialize forgot StatusBin/rarity_status_map[{}]/categories_progress_map: {}",
rarity_items.rarity, policy_tag
));
if policy.included_category_tags.contains(category_tag) {
*prev_failure = 0;
} else {
*prev_failure += 1;
}
}
}
fn update_discount<'bin, 'conf>(
gacha_bin: &'bin mut GachaModelBin,
target_pool: &'conf CharacterGachaPool,
category_tag: &String,
rarity_items: &GachaAvailableItemsInfo,
) {
let gachaconf = gacha::global_gacha_config();
for (policy_tag, policy) in gachaconf.discount_policies.must_gain_item_map.iter() {
if *category_tag != policy.category_tag {
continue;
}
if !target_pool.discount_policy_tags.contains(policy_tag) {
continue;
}
let status_bin = gacha_bin
.gacha_status_map
.get_mut(&target_pool.sharing_guarantee_info_category)
.unwrap();
let usage = status_bin.discount_usage_map.get_mut(policy_tag).unwrap();
if *usage < policy.use_limit {
*usage += 1;
}
}
for (policy_tag, policy) in gachaconf.discount_policies.advanced_guarantee_map.iter() {
if rarity_items.rarity != policy.rarity {
continue;
}
if !target_pool.discount_policy_tags.contains(policy_tag) {
continue;
}
let status_bin = gacha_bin
.gacha_status_map
.get_mut(&target_pool.sharing_guarantee_info_category)
.unwrap();
let usage = status_bin.discount_usage_map.get_mut(policy_tag).unwrap();
if *usage < policy.use_limit {
*usage += 1;
}
}
}

View file

@ -0,0 +1,4 @@
mod gacha_model;
mod record;
pub use gacha_model::GachaModel;

View file

View file

@ -1,5 +1,6 @@
pub mod battle;
mod enums;
pub mod gacha;
pub mod game;
pub mod item;
pub mod math;

View file

@ -1,6 +1,7 @@
use data::tables::{self, AvatarBaseID};
use proto::{ItemStatic, PlayerDataBin, Retcode};
use super::gacha::GachaModel;
use super::game::{FrontendGame, FrontendGameError, GameInstance, LogicError};
use super::item::{ItemModel, ItemUID};
use super::main_city_model::MainCityModel;
@ -16,6 +17,7 @@ pub struct Player {
pub role_model: RoleModel,
pub item_model: ItemModel,
pub main_city_model: MainCityModel,
pub gacha_model: GachaModel,
}
impl Player {
@ -28,6 +30,7 @@ impl Player {
role_model: Some(self.role_model.to_bin()),
item_model: Some(self.item_model.to_bin()),
main_city_model: Some(self.main_city_model.to_bin()),
gacha_model: Some(self.gacha_model.to_bin()),
}
}
@ -44,6 +47,7 @@ impl Player {
.main_city_model
.map(MainCityModel::from_bin)
.unwrap_or_default(),
gacha_model: bin.gacha_model.map(GachaModel::from_bin).unwrap_or_default(),
..Default::default()
}
}
@ -58,6 +62,12 @@ impl Player {
.add_resource(ItemStatic::FrontendGold as u32, 1_000_000);
self.item_model
.add_resource(ItemStatic::GameDiamond as u32, 1_000_000);
self.item_model
.add_resource(ItemStatic::GachaTicketEvent as u32, 30_000);
self.item_model
.add_resource(ItemStatic::GachaTicketStandard as u32, 30_000);
self.item_model
.add_resource(ItemStatic::GachaTicketBangboo as u32, 30_000);
self.item_model.add_resource(ItemStatic::Energy as u32, 240);
}

View file

@ -247,4 +247,8 @@ impl NetSession {
pub fn set_state(&self, state: NetSessionState) {
self.state.store(state, std::sync::atomic::Ordering::SeqCst);
}
pub async fn shutdown(&self) -> Result<(), std::io::Error> {
self.writer.lock().await.shutdown().await
}
}

View file

@ -227,7 +227,7 @@ pub struct Nkhnlakggmj {
pub iddehlcpjjn: ::prost::alloc::string::String,
#[xor(10163)]
#[prost(int64, tag = "14")]
pub phkcdmjheen: i64,
pub end_timestamp: i64,
#[xor(8852)]
#[prost(uint32, tag = "8")]
pub ppnbkmndpjc: u32,
@ -829,7 +829,7 @@ pub struct Fkkojjgepnb {
pub lchdjcdjiik: u32,
#[xor(4851)]
#[prost(int64, tag = "3")]
pub phkcdmjheen: i64,
pub end_timestamp: i64,
#[xor(8589)]
#[prost(int32, tag = "505")]
pub lecpejadije: i32,
@ -4512,7 +4512,7 @@ pub struct Kancdiinhgh {
#[prost(uint64, tag = "2")]
pub dbkpbkpcoog: u64,
#[prost(uint64, tag = "3")]
pub phkcdmjheen: u64,
pub end_timestamp: u64,
}
#[derive(proto_gen::CmdID)]
#[cmdid(2438)]
@ -8223,7 +8223,7 @@ pub struct Ihhaahinlik {
#[prost(int64, tag = "3")]
pub dbkpbkpcoog: i64,
#[prost(int64, tag = "4")]
pub phkcdmjheen: i64,
pub end_timestamp: i64,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -9108,7 +9108,7 @@ pub struct Gkfhklbbcpo {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Enkkecgonaf {
#[prost(uint32, tag = "1")]
pub abalhhfapla: u32,
pub cost_item_count: u32,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -9603,7 +9603,7 @@ pub struct Gfpehbhpgfb {
pub avatars: ::prost::alloc::vec::Vec<u32>,
#[xor(8960)]
#[prost(uint32, tag = "14")]
pub abalhhfapla: u32,
pub cost_item_count: u32,
#[xor(8889)]
#[prost(uint32, tag = "6")]
pub damhjcgieco: u32,
@ -9668,7 +9668,7 @@ pub struct Cbccakknimc {
pub struct Bfkkjofnjjo {
#[xor(4795)]
#[prost(uint32, tag = "10")]
pub abalhhfapla: u32,
pub cost_item_count: u32,
#[xor(5066)]
#[prost(uint32, tag = "4")]
pub cmacbfkaoma: u32,
@ -10605,7 +10605,7 @@ pub struct Npdgpemipij {
#[prost(int32, tag = "5")]
pub peamchapinf: i32,
#[prost(string, tag = "2")]
pub phkcdmjheen: ::prost::alloc::string::String,
pub end_timestamp: ::prost::alloc::string::String,
}
#[derive(proto_gen::CmdID)]
#[cmdid(5101)]
@ -12389,7 +12389,7 @@ pub struct InteractWithUnitCsReq {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Ofcdfiihahe {
#[prost(uint32, tag = "1")]
pub abalhhfapla: u32,
pub cost_item_count: u32,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -12926,7 +12926,7 @@ pub struct Hdjijldgmab {
pub struct Cnmgfcllhpl {
#[xor(11487)]
#[prost(uint32, tag = "3")]
pub dcealmadfgi: u32,
pub gacha_parent_schedule_id: u32,
}
#[derive(proto_gen::CmdID)]
#[cmdid(665)]
@ -13423,7 +13423,7 @@ pub struct Jlldijenmoc {
pub dphghojclod: u32,
#[xor(8783)]
#[prost(int64, tag = "2")]
pub phkcdmjheen: i64,
pub end_timestamp: i64,
#[xor(525)]
#[prost(uint32, tag = "8")]
pub leagnodilli: u32,
@ -13731,19 +13731,19 @@ pub struct Omdfkjoopce {
#[derive(proto_gen::XorFields)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Effclengcpo {
pub struct DoGachaCsReq {
#[xor(13734)]
#[prost(uint32, tag = "15")]
pub eglpecifagd: u32,
#[xor(4101)]
#[prost(uint32, tag = "1")]
pub dcealmadfgi: u32,
pub gacha_parent_schedule_id: u32,
#[xor(8588)]
#[prost(uint32, tag = "13")]
pub madciamhahg: u32,
pub random_number: u32,
#[xor(10835)]
#[prost(uint32, tag = "3")]
pub abalhhfapla: u32,
pub cost_item_count: u32,
#[xor(3853)]
#[prost(uint32, tag = "5")]
pub gacha_type: u32,
@ -14035,10 +14035,10 @@ pub struct Nffblkigaan {
pub weapon_uid: u32,
#[xor(2492)]
#[prost(uint32, tag = "9")]
pub eijhjbplhih: u32,
pub need_item_id: u32,
#[xor(13312)]
#[prost(uint32, tag = "8")]
pub bplmpghdklb: u32,
pub need_item_count: u32,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -15705,7 +15705,7 @@ pub struct Gcffmmdgobe {
#[prost(int32, tag = "1")]
pub opmgaofadph: i32,
#[prost(int32, tag = "2")]
pub abalhhfapla: i32,
pub cost_item_count: i32,
}
#[derive(proto_gen::CmdID)]
#[cmdid(1224)]
@ -16201,13 +16201,13 @@ pub struct ClientSystemsInfo {
#[derive(proto_gen::XorFields)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Feanepokfam {
pub struct NeedItemInfo {
#[xor(156)]
#[prost(uint32, tag = "15")]
pub bplmpghdklb: u32,
pub need_item_count: u32,
#[xor(11997)]
#[prost(uint32, tag = "5")]
pub eijhjbplhih: u32,
pub need_item_id: u32,
}
#[derive(proto_gen::CmdID)]
#[cmdid(1140)]
@ -16647,14 +16647,14 @@ pub struct Ejjimjcohgg {
#[derive(proto_gen::XorFields)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Akjiehealco {
pub struct DoGachaScRsp {
#[prost(message, optional, tag = "6")]
pub gacha_data: ::core::option::Option<GachaData>,
#[prost(message, repeated, tag = "13")]
pub mjajbddaemm: ::prost::alloc::vec::Vec<Depahhdodeb>,
pub gain_item_list: ::prost::alloc::vec::Vec<GainItemInfo>,
#[xor(12395)]
#[prost(uint32, tag = "11")]
pub abalhhfapla: u32,
pub cost_item_count: u32,
#[xor(14106)]
#[prost(int32, tag = "5")]
pub retcode: i32,
@ -17252,7 +17252,7 @@ pub struct Ipfpofcbnjp {
pub struct Ilehibpgief {
#[xor(14424)]
#[prost(int64, tag = "4")]
pub phkcdmjheen: i64,
pub end_timestamp: i64,
#[prost(uint32, repeated, tag = "6")]
pub pjilpbkknan: ::prost::alloc::vec::Vec<u32>,
#[xor(4341)]
@ -17842,7 +17842,7 @@ pub struct Odijcgldmia {
#[prost(uint32, tag = "11")]
pub bpegheknole: u32,
#[prost(message, repeated, tag = "14")]
pub bapbocgilep: ::prost::alloc::vec::Vec<Feanepokfam>,
pub bapbocgilep: ::prost::alloc::vec::Vec<NeedItemInfo>,
#[prost(map = "uint32, uint32", tag = "10")]
pub maeegjdknkg: ::std::collections::HashMap<u32, u32>,
#[prost(uint32, repeated, tag = "9")]
@ -17850,20 +17850,20 @@ pub struct Odijcgldmia {
#[prost(string, tag = "3")]
pub fnanndecaan: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "13")]
pub pbalmllekpp: ::prost::alloc::vec::Vec<Feanepokfam>,
pub need_item_info_list: ::prost::alloc::vec::Vec<NeedItemInfo>,
#[prost(message, repeated, tag = "6")]
pub mplcofohjnl: ::prost::alloc::vec::Vec<Feanepokfam>,
pub mplcofohjnl: ::prost::alloc::vec::Vec<NeedItemInfo>,
#[xor(5947)]
#[prost(uint32, tag = "5")]
pub r#type: u32,
#[prost(message, repeated, tag = "8")]
pub dnadnehoogk: ::prost::alloc::vec::Vec<Feanepokfam>,
pub dnadnehoogk: ::prost::alloc::vec::Vec<NeedItemInfo>,
#[xor(5194)]
#[prost(uint32, tag = "1")]
pub dgaafhidocl: u32,
#[xor(11358)]
#[prost(uint32, tag = "12")]
pub dcealmadfgi: u32,
pub gacha_parent_schedule_id: u32,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -18737,7 +18737,7 @@ pub struct Ilghjldjhcl {
pub hbmnikpdgon: ::prost::alloc::string::String,
#[xor(9518)]
#[prost(int64, tag = "9")]
pub phkcdmjheen: i64,
pub end_timestamp: i64,
#[xor(1810)]
#[prost(uint32, tag = "1")]
pub oeaieooemng: u32,
@ -18990,7 +18990,7 @@ pub struct Cobgikcepkp {
#[prost(int32, tag = "1")]
pub imhfejennof: i32,
#[prost(string, tag = "4")]
pub phkcdmjheen: ::prost::alloc::string::String,
pub end_timestamp: ::prost::alloc::string::String,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -22212,9 +22212,9 @@ pub struct Mbokdhgpobc {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Gacha {
#[prost(uint32, repeated, tag = "1425")]
pub jkbfeediiho: ::prost::alloc::vec::Vec<u32>,
pub chooseable_up_list: ::prost::alloc::vec::Vec<u32>,
#[prost(uint32, repeated, tag = "15")]
pub nfngmliibdf: ::prost::alloc::vec::Vec<u32>,
pub up_s_item_list: ::prost::alloc::vec::Vec<u32>,
#[xor(1098)]
#[prost(uint32, tag = "11")]
pub obabhacfokn: u32,
@ -22222,7 +22222,7 @@ pub struct Gacha {
pub ioiebkbcnoi: ::prost::alloc::string::String,
#[xor(13960)]
#[prost(uint32, tag = "698")]
pub gbmmbcbefmp: u32,
pub advanced_s_guarantee: u32,
#[xor(1462)]
#[prost(uint32, tag = "10")]
pub kagiddohcmk: u32,
@ -22230,30 +22230,30 @@ pub struct Gacha {
#[prost(uint32, tag = "1921")]
pub nammdglepbk: u32,
#[prost(message, repeated, tag = "3")]
pub pbalmllekpp: ::prost::alloc::vec::Vec<Feanepokfam>,
pub need_item_info_list: ::prost::alloc::vec::Vec<NeedItemInfo>,
#[xor(9792)]
#[prost(int64, tag = "14")]
pub phkcdmjheen: i64,
pub end_timestamp: i64,
#[xor(6233)]
#[prost(uint32, tag = "563")]
pub dimlpkbggfc: u32,
pub discount_ten_roll_prize: u32,
#[prost(bool, tag = "1756")]
pub nkeigieepgn: bool,
#[prost(uint32, repeated, tag = "755")]
pub hbhckgpjian: ::prost::alloc::vec::Vec<u32>,
pub free_select_item_list: ::prost::alloc::vec::Vec<u32>,
#[prost(string, tag = "2")]
pub mpmnlphpdlk: ::prost::alloc::string::String,
pub drop_history_webview: ::prost::alloc::string::String,
#[xor(4816)]
#[prost(uint32, tag = "13")]
pub pladpclalgn: u32,
pub gacha_schedule_id: u32,
#[xor(11392)]
#[prost(uint32, tag = "574")]
pub fjhglcclbgm: u32,
pub free_select_required_pull: u32,
#[prost(uint32, repeated, tag = "6")]
pub goainlmbhnn: ::prost::alloc::vec::Vec<u32>,
pub up_a_item_list: ::prost::alloc::vec::Vec<u32>,
#[xor(8288)]
#[prost(uint32, tag = "12")]
pub dcealmadfgi: u32,
pub gacha_parent_schedule_id: u32,
#[xor(8537)]
#[prost(uint32, tag = "1662")]
pub pcjdafaaimg: u32,
@ -22273,26 +22273,26 @@ pub struct Gacha {
pub gacha_type: u32,
#[xor(5057)]
#[prost(uint32, tag = "244")]
pub ahidoimfiof: u32,
pub s_guarantee: u32,
#[xor(1870)]
#[prost(int64, tag = "8")]
pub start_timestamp: i64,
#[xor(562)]
#[prost(uint32, tag = "726")]
pub mkiplhjemoi: u32,
pub free_select_progress: u32,
#[xor(8338)]
#[prost(uint32, tag = "96")]
pub ihjnkoijdgh: u32,
#[xor(4210)]
#[prost(uint32, tag = "789")]
pub gokmdbojehm: u32,
pub a_guarantee: u32,
#[prost(uint32, repeated, tag = "4")]
pub akggbhgkifd: ::prost::alloc::vec::Vec<u32>,
#[xor(1056)]
#[prost(uint32, tag = "2002")]
pub kikannccmmo: u32,
pub discount_avaliable_num: u32,
#[prost(string, tag = "7")]
pub jahbjmphipl: ::prost::alloc::string::String,
pub gacha_info_list_webview: ::prost::alloc::string::String,
#[xor(9009)]
#[prost(uint32, tag = "419")]
pub ekjlhhdekka: u32,
@ -22699,7 +22699,7 @@ pub struct Mcjgjlpjfjc {
pub gebpolkeieh: u32,
#[xor(4412)]
#[prost(int64, tag = "1")]
pub phkcdmjheen: i64,
pub end_timestamp: i64,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -23294,7 +23294,7 @@ pub struct GachaData {
pub cmamhfldihg: ::core::option::Option<Dpgipnmocnj>,
#[xor(9369)]
#[prost(uint32, tag = "13")]
pub madciamhahg: u32,
pub random_number: u32,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -23399,7 +23399,7 @@ pub struct Nalkdbjimgk {
pub aohakmnfinf: u32,
#[xor(2280)]
#[prost(uint32, tag = "4")]
pub dcealmadfgi: u32,
pub gacha_parent_schedule_id: u32,
}
#[derive(proto_gen::CmdID)]
#[cmdid(4620)]
@ -24021,7 +24021,7 @@ pub struct Himappelgdm {
pub gppmclpnjoe: u32,
#[xor(4244)]
#[prost(uint64, tag = "11")]
pub phkcdmjheen: u64,
pub end_timestamp: u64,
#[xor(6824)]
#[prost(uint32, tag = "7")]
pub enhandfaalc: u32,
@ -24564,7 +24564,7 @@ pub struct Pahjnbjogon {
pub item_id: u32,
#[xor(1511)]
#[prost(uint32, tag = "1")]
pub dcealmadfgi: u32,
pub gacha_parent_schedule_id: u32,
}
#[derive(proto_gen::CmdID)]
#[derive(proto_gen::XorFields)]
@ -24653,7 +24653,7 @@ pub struct Eindafcpkce {
#[prost(int32, tag = "1")]
pub nkiegkopoeg: i32,
#[prost(int32, tag = "2")]
pub abalhhfapla: i32,
pub cost_item_count: i32,
}
#[derive(proto_gen::CmdID)]
#[cmdid(3276)]
@ -26395,7 +26395,7 @@ pub struct Pfcmihnfmme {
pub cfnblioopmp: u32,
#[xor(13350)]
#[prost(int64, tag = "15")]
pub phkcdmjheen: i64,
pub end_timestamp: i64,
#[xor(13289)]
#[prost(int64, tag = "5")]
pub kehdpankopd: i64,
@ -27534,7 +27534,7 @@ pub struct TipsInfo {
pub struct Ieimfkpmegp {
#[xor(378)]
#[prost(uint32, tag = "12")]
pub dcealmadfgi: u32,
pub gacha_parent_schedule_id: u32,
#[xor(1946)]
#[prost(uint32, tag = "7")]
pub avatar_id: u32,
@ -28249,8 +28249,8 @@ pub struct Flpgnabkedc {
#[derive(proto_gen::XorFields)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Igapopdfcef {
#[prost(enumeration = "Obpfhejepck", tag = "15")]
pub struct DisconnectScNotify {
#[prost(enumeration = "DisconnectReason", tag = "15")]
pub reason: i32,
}
#[derive(proto_gen::CmdID)]
@ -31149,7 +31149,7 @@ pub struct Bgheihedbcb {
pub apociobpoho: u32,
#[xor(9137)]
#[prost(int64, tag = "2")]
pub phkcdmjheen: i64,
pub end_timestamp: i64,
#[prost(bool, tag = "4")]
pub mgfcmlpkjkg: bool,
#[xor(438)]
@ -31470,7 +31470,7 @@ pub struct Nnbooaekcml {
pub ncjcmkgfpej: ::prost::alloc::vec::Vec<Bnpkpfadbdd>,
#[xor(15963)]
#[prost(int32, tag = "13")]
pub eijhjbplhih: i32,
pub need_item_id: i32,
}
#[derive(proto_gen::CmdID)]
#[cmdid(816)]
@ -32445,21 +32445,21 @@ pub struct Mkaecbehadi {
#[derive(proto_gen::XorFields)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Depahhdodeb {
pub struct GainItemInfo {
#[xor(9764)]
#[prost(uint32, tag = "5")]
pub num: u32,
#[xor(12647)]
#[prost(uint32, tag = "2")]
pub ollapieolpm: u32,
pub extra_item_count: u32,
#[prost(map = "uint32, uint32", tag = "4")]
pub nkdheebkjjl: ::std::collections::HashMap<u32, u32>,
pub extra_items: ::std::collections::HashMap<u32, u32>,
#[xor(11858)]
#[prost(uint32, tag = "11")]
pub item_id: u32,
#[xor(6146)]
#[prost(uint32, tag = "8")]
pub dghfjhiikkn: u32,
pub extra_item_id: u32,
#[xor(10021)]
#[prost(uint32, tag = "9")]
pub uid: u32,
@ -32766,7 +32766,7 @@ pub struct Lipadknfagg {
pub abdfdamklia: bool,
#[xor(1841)]
#[prost(int64, tag = "1696")]
pub phkcdmjheen: i64,
pub end_timestamp: i64,
#[xor(15522)]
#[prost(int64, tag = "14")]
pub jkjhhbpcaon: i64,
@ -32871,7 +32871,7 @@ pub struct Gojokjnppnp {
pub mlfannobjdp: bool,
#[xor(1038)]
#[prost(int64, tag = "4")]
pub phkcdmjheen: i64,
pub end_timestamp: i64,
#[xor(5317)]
#[prost(uint32, tag = "14")]
pub ialhcipedom: u32,
@ -54259,9 +54259,9 @@ pub enum ItemStatic {
FrontendGold = 10,
GameDiamond = 100,
RechargeDiamond = 101,
Lcdlfoheaim = 110,
Mndhfchkhcl = 111,
Fcffdnjnemf = 112,
GachaTicketStandard = 110,
GachaTicketEvent = 111,
GachaTicketBangboo = 112,
Exp = 201,
Energy = 501,
Gdglcfmgoji = 3000001,
@ -54280,9 +54280,9 @@ impl ItemStatic {
ItemStatic::FrontendGold => "ITEM_STATIC_FRONTEND_GOLD",
ItemStatic::GameDiamond => "ITEM_STATIC_GAME_DIAMOND",
ItemStatic::RechargeDiamond => "ITEM_STATIC_RECHARGE_DIAMOND",
ItemStatic::Lcdlfoheaim => "ItemStatic_LCDLFOHEAIM",
ItemStatic::Mndhfchkhcl => "ItemStatic_MNDHFCHKHCL",
ItemStatic::Fcffdnjnemf => "ItemStatic_FCFFDNJNEMF",
ItemStatic::GachaTicketStandard => "ItemStatic_GACHA_TICKET_STANDARD",
ItemStatic::GachaTicketEvent => "ItemStatic_GACHA_TICKET_EVENT",
ItemStatic::GachaTicketBangboo => "ItemStatic_GACHA_TICKET_BANGBOO",
ItemStatic::Exp => "ITEM_STATIC_EXP",
ItemStatic::Energy => "ITEM_STATIC_ENERGY",
ItemStatic::Gdglcfmgoji => "ItemStatic_GDGLCFMGOJI",
@ -54298,9 +54298,9 @@ impl ItemStatic {
"ITEM_STATIC_FRONTEND_GOLD" => Some(Self::FrontendGold),
"ITEM_STATIC_GAME_DIAMOND" => Some(Self::GameDiamond),
"ITEM_STATIC_RECHARGE_DIAMOND" => Some(Self::RechargeDiamond),
"ItemStatic_LCDLFOHEAIM" => Some(Self::Lcdlfoheaim),
"ItemStatic_MNDHFCHKHCL" => Some(Self::Mndhfchkhcl),
"ItemStatic_FCFFDNJNEMF" => Some(Self::Fcffdnjnemf),
"ItemStatic_GACHA_TICKET_STANDARD" => Some(Self::GachaTicketStandard),
"ItemStatic_GACHA_TICKET_EVENT" => Some(Self::GachaTicketEvent),
"ItemStatic_GACHA_TICKET_BANGBOO" => Some(Self::GachaTicketBangboo),
"ITEM_STATIC_EXP" => Some(Self::Exp),
"ITEM_STATIC_ENERGY" => Some(Self::Energy),
"ItemStatic_GDGLCFMGOJI" => Some(Self::Gdglcfmgoji),
@ -55320,50 +55320,62 @@ impl Jiedoddkipa {
#[derive(proto_gen::XorFields)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Obpfhejepck {
pub enum DisconnectReason {
Domjllafeac = 0,
Gdbjccehcdb = 1,
/// 您的账号在其他地方登录,请检查是否存在账号泄露风险,是否要重新登录游戏?
ServerRelogin = 1,
Clcbejonokn = 2,
Jlimlghggke = 3,
Omjjggajcbh = 4,
Kdpiceebneb = 5,
/// 游戏正在维护中,请等维护完成后再尝试登录。
ServerShutdown = 3,
/// UID:"3"
/// 您已掉线,请返回登录界面重试
ServerKick = 4,
/// 登录状态已失效,请重新登录
AccountPasswordChange = 5,
/// 您已断开链接,请重新登录
Nmcpihldicf = 6,
/// 您的卡死问题已处理完成,请重新登录游戏
Ihcmpplkgkn = 7,
/// 您的PSN™的好友关系已解绑现在可自由处理游戏内好友关系
Lgjemnlahcp = 8,
Mfgomdhiejh = 9,
}
impl Obpfhejepck {
impl DisconnectReason {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Obpfhejepck::Domjllafeac => "OBPFHEJEPCK_DOMJLLAFEAC",
Obpfhejepck::Gdbjccehcdb => "OBPFHEJEPCK_GDBJCCEHCDB",
Obpfhejepck::Clcbejonokn => "OBPFHEJEPCK_CLCBEJONOKN",
Obpfhejepck::Jlimlghggke => "OBPFHEJEPCK_JLIMLGHGGKE",
Obpfhejepck::Omjjggajcbh => "OBPFHEJEPCK_OMJJGGAJCBH",
Obpfhejepck::Kdpiceebneb => "OBPFHEJEPCK_KDPICEEBNEB",
Obpfhejepck::Nmcpihldicf => "OBPFHEJEPCK_NMCPIHLDICF",
Obpfhejepck::Ihcmpplkgkn => "OBPFHEJEPCK_IHCMPPLKGKN",
Obpfhejepck::Lgjemnlahcp => "OBPFHEJEPCK_LGJEMNLAHCP",
Obpfhejepck::Mfgomdhiejh => "OBPFHEJEPCK_MFGOMDHIEJH",
DisconnectReason::Domjllafeac => "DISCONNECT_REASON_DOMJLLAFEAC",
DisconnectReason::ServerRelogin => "DISCONNECT_REASON_SERVER_RELOGIN",
DisconnectReason::Clcbejonokn => "DISCONNECT_REASON_CLCBEJONOKN",
DisconnectReason::ServerShutdown => "DISCONNECT_REASON_SERVER_SHUTDOWN",
DisconnectReason::ServerKick => "DISCONNECT_REASON_SERVER_KICK",
DisconnectReason::AccountPasswordChange => {
"DISCONNECT_REASON_ACCOUNT_PASSWORD_CHANGE"
}
DisconnectReason::Nmcpihldicf => "DISCONNECT_REASON_NMCPIHLDICF",
DisconnectReason::Ihcmpplkgkn => "DISCONNECT_REASON_IHCMPPLKGKN",
DisconnectReason::Lgjemnlahcp => "DISCONNECT_REASON_LGJEMNLAHCP",
DisconnectReason::Mfgomdhiejh => "DISCONNECT_REASON_MFGOMDHIEJH",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"OBPFHEJEPCK_DOMJLLAFEAC" => Some(Self::Domjllafeac),
"OBPFHEJEPCK_GDBJCCEHCDB" => Some(Self::Gdbjccehcdb),
"OBPFHEJEPCK_CLCBEJONOKN" => Some(Self::Clcbejonokn),
"OBPFHEJEPCK_JLIMLGHGGKE" => Some(Self::Jlimlghggke),
"OBPFHEJEPCK_OMJJGGAJCBH" => Some(Self::Omjjggajcbh),
"OBPFHEJEPCK_KDPICEEBNEB" => Some(Self::Kdpiceebneb),
"OBPFHEJEPCK_NMCPIHLDICF" => Some(Self::Nmcpihldicf),
"OBPFHEJEPCK_IHCMPPLKGKN" => Some(Self::Ihcmpplkgkn),
"OBPFHEJEPCK_LGJEMNLAHCP" => Some(Self::Lgjemnlahcp),
"OBPFHEJEPCK_MFGOMDHIEJH" => Some(Self::Mfgomdhiejh),
"DISCONNECT_REASON_DOMJLLAFEAC" => Some(Self::Domjllafeac),
"DISCONNECT_REASON_SERVER_RELOGIN" => Some(Self::ServerRelogin),
"DISCONNECT_REASON_CLCBEJONOKN" => Some(Self::Clcbejonokn),
"DISCONNECT_REASON_SERVER_SHUTDOWN" => Some(Self::ServerShutdown),
"DISCONNECT_REASON_SERVER_KICK" => Some(Self::ServerKick),
"DISCONNECT_REASON_ACCOUNT_PASSWORD_CHANGE" => {
Some(Self::AccountPasswordChange)
}
"DISCONNECT_REASON_NMCPIHLDICF" => Some(Self::Nmcpihldicf),
"DISCONNECT_REASON_IHCMPPLKGKN" => Some(Self::Ihcmpplkgkn),
"DISCONNECT_REASON_LGJEMNLAHCP" => Some(Self::Lgjemnlahcp),
"DISCONNECT_REASON_MFGOMDHIEJH" => Some(Self::Mfgomdhiejh),
_ => None,
}
}

View file

@ -119,6 +119,77 @@ pub struct MainCityModelBin {
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GachaProgressBin {
/// The pity (counting how many pulls) of this pull (in previous record) or the next pull (in status).
#[prost(uint32, tag = "1")]
pub pity: u32,
/// The failure times of this category.
#[prost(map = "string, uint32", tag = "2")]
pub categories_progress_map: ::std::collections::HashMap<
::prost::alloc::string::String,
u32,
>,
/// The selected priority for a Chooseable category.
#[prost(map = "string, string", tag = "3")]
pub category_chosen_guarantee_map: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GachaExtraItemBin {
#[prost(uint32, tag = "1")]
pub extra_item_id: u32,
#[prost(uint32, tag = "2")]
pub extra_item_count: u32,
/// How many objects of the main item obtained in gacha is present in the player's bag (before gacha).
/// This is used for something like converting when there're extra characters.
#[prost(uint32, tag = "3")]
pub currently_gained: u32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GachaRecordBin {
#[prost(int64, tag = "1")]
pub pull_timestamp: i64,
#[prost(uint32, tag = "2")]
pub obtained_item_id: u32,
#[prost(uint32, tag = "3")]
pub gacha_id: u32,
/// The progress BEFORE this gacha is performed. uint32 is rarity.
#[prost(map = "uint32, message", tag = "4")]
pub progress_map: ::std::collections::HashMap<u32, GachaProgressBin>,
#[prost(message, optional, tag = "5")]
pub extra_item_bin: ::core::option::Option<GachaExtraItemBin>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GachaStatusBin {
#[prost(map = "uint32, message", tag = "1")]
pub rarity_status_map: ::std::collections::HashMap<u32, GachaProgressBin>,
#[prost(map = "string, uint32", tag = "2")]
pub discount_usage_map: ::std::collections::HashMap<
::prost::alloc::string::String,
u32,
>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GachaModelBin {
/// Gacha Status query. string is sharing_guarantee_info_category.
#[prost(map = "string, message", tag = "1")]
pub gacha_status_map: ::std::collections::HashMap<
::prost::alloc::string::String,
GachaStatusBin,
>,
#[prost(message, repeated, tag = "2")]
pub gacha_records: ::prost::alloc::vec::Vec<GachaRecordBin>,
#[prost(uint32, tag = "3")]
pub random_number: u32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PlayerDataBin {
#[prost(message, optional, tag = "1")]
pub basic_data_model: ::core::option::Option<BasicDataModelBin>,
@ -130,4 +201,6 @@ pub struct PlayerDataBin {
pub item_model: ::core::option::Option<ItemModelBin>,
#[prost(message, optional, tag = "5")]
pub main_city_model: ::core::option::Option<MainCityModelBin>,
#[prost(message, optional, tag = "6")]
pub gacha_model: ::core::option::Option<GachaModelBin>,
}