forked from blasthavers/blastmud
Implement a 'poverty discount' to help players stuck with no money.
This commit is contained in:
parent
8461f36fa6
commit
752af74337
@ -4,7 +4,10 @@ use super::{
|
|||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
models::item::Item,
|
models::item::Item,
|
||||||
services::capacity::{check_item_capacity, check_item_ref_capacity, CapacityLevel},
|
services::{
|
||||||
|
capacity::{check_item_capacity, check_item_ref_capacity, CapacityLevel},
|
||||||
|
urges::change_stress_considering_cool,
|
||||||
|
},
|
||||||
static_content::possession_type::possession_data,
|
static_content::possession_type::possession_data,
|
||||||
static_content::room,
|
static_content::room,
|
||||||
};
|
};
|
||||||
@ -68,12 +71,35 @@ impl UserVerb for Verb {
|
|||||||
{
|
{
|
||||||
if offset_remaining <= 1 {
|
if offset_remaining <= 1 {
|
||||||
if let Some(user) = ctx.user_dat.as_mut() {
|
if let Some(user) = ctx.user_dat.as_mut() {
|
||||||
|
let mut paid_price = stock.list_price;
|
||||||
if user.credits < stock.list_price {
|
if user.credits < stock.list_price {
|
||||||
user_error(
|
if stock.poverty_discount {
|
||||||
"You don't have enough credits to buy that!".to_owned(),
|
if let Some(urges) = player_item.urges.as_ref() {
|
||||||
)?;
|
if urges.stress.value > 500 {
|
||||||
|
user_error(ansi!("You don't have the money to pay full price, \
|
||||||
|
and are too tired to try begging for a \
|
||||||
|
discount. [Hint: Try to <bold>recline<reset> \
|
||||||
|
for a bit and try again]").to_owned())?;
|
||||||
|
}
|
||||||
|
let mut player_item_mut = (*player_item).clone();
|
||||||
|
change_stress_considering_cool(
|
||||||
|
&ctx.trans,
|
||||||
|
&mut player_item_mut,
|
||||||
|
2000,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
ctx.trans.save_item_model(&player_item_mut).await?;
|
||||||
|
}
|
||||||
|
paid_price = user.credits;
|
||||||
|
user.credits = 0;
|
||||||
|
} else {
|
||||||
|
user_error(
|
||||||
|
"You don't have enough credits to buy that!".to_owned(),
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
user.credits -= stock.list_price;
|
||||||
}
|
}
|
||||||
user.credits -= stock.list_price;
|
|
||||||
let player_item_str = player_item.refstr();
|
let player_item_str = player_item.refstr();
|
||||||
let item_code = ctx.trans.alloc_item_code().await?;
|
let item_code = ctx.trans.alloc_item_code().await?;
|
||||||
let loc = match check_item_capacity(
|
let loc = match check_item_capacity(
|
||||||
@ -133,7 +159,7 @@ impl UserVerb for Verb {
|
|||||||
&ctx.session,
|
&ctx.session,
|
||||||
Some(&format!(
|
Some(&format!(
|
||||||
"Your wristpad beeps for a deduction of {} credits.\n",
|
"Your wristpad beeps for a deduction of {} credits.\n",
|
||||||
stock.list_price
|
paid_price
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
use super::{get_player_item_or_fail, user_error, UResult, UserVerb, UserVerbRef, VerbContext};
|
use super::{
|
||||||
|
get_player_item_or_fail, get_user_or_fail, user_error, UResult, UserVerb, UserVerbRef,
|
||||||
|
VerbContext,
|
||||||
|
};
|
||||||
use crate::{language, static_content::possession_type::possession_data, static_content::room};
|
use crate::{language, static_content::possession_type::possession_data, static_content::room};
|
||||||
use ansi::ansi;
|
use ansi::ansi;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -13,6 +16,7 @@ impl UserVerb for Verb {
|
|||||||
_remaining: &str,
|
_remaining: &str,
|
||||||
) -> UResult<()> {
|
) -> UResult<()> {
|
||||||
let player_item = get_player_item_or_fail(ctx).await?;
|
let player_item = get_player_item_or_fail(ctx).await?;
|
||||||
|
let user = get_user_or_fail(ctx)?;
|
||||||
|
|
||||||
if player_item.death_data.is_some() {
|
if player_item.death_data.is_some() {
|
||||||
user_error(
|
user_error(
|
||||||
@ -51,10 +55,16 @@ impl UserVerb for Verb {
|
|||||||
} else {
|
} else {
|
||||||
&possession_type.display
|
&possession_type.display
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut price = stock.list_price;
|
||||||
|
if stock.poverty_discount && price > user.credits {
|
||||||
|
price = user.credits;
|
||||||
|
}
|
||||||
|
|
||||||
msg.push_str(&format!(
|
msg.push_str(&format!(
|
||||||
"| {:40} | {:15.2} |\n",
|
"| {:40} | {:15.2} |\n",
|
||||||
&language::caps_first(&display),
|
&language::caps_first(&display),
|
||||||
&stock.list_price
|
&price
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ pub async fn recalculate_urge_growth(_trans: &DBTrans, item: &mut Item) -> DResu
|
|||||||
..old_urges.bladder
|
..old_urges.bladder
|
||||||
},
|
},
|
||||||
stress: Urge {
|
stress: Urge {
|
||||||
growth: (-(cool.max(7.0) - 7.0) * 4.0 * relax_action_factor) as i16,
|
growth: (-(cool.max(7.0) - 7.0) * 10.0 * relax_action_factor) as i16,
|
||||||
..old_urges.stress
|
..old_urges.stress
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -276,6 +276,7 @@ pub struct SecondaryZoneRecord {
|
|||||||
pub struct RoomStock {
|
pub struct RoomStock {
|
||||||
pub possession_type: PossessionType,
|
pub possession_type: PossessionType,
|
||||||
pub list_price: u64,
|
pub list_price: u64,
|
||||||
|
pub poverty_discount: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for RoomStock {
|
impl Default for RoomStock {
|
||||||
@ -283,6 +284,7 @@ impl Default for RoomStock {
|
|||||||
Self {
|
Self {
|
||||||
possession_type: PossessionType::AntennaWhip,
|
possession_type: PossessionType::AntennaWhip,
|
||||||
list_price: 1000000000,
|
list_price: 1000000000,
|
||||||
|
poverty_discount: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,7 @@ pub fn room_list() -> Vec<Room> {
|
|||||||
RoomStock {
|
RoomStock {
|
||||||
possession_type: PossessionType::GreasyBurger,
|
possession_type: PossessionType::GreasyBurger,
|
||||||
list_price: 5,
|
list_price: 5,
|
||||||
|
poverty_discount: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user