diff --git a/lib/Lacuna/DB/Result/Promotion.pm b/lib/Lacuna/DB/Result/Promotion.pm index 15d55af6..3bde6f3d 100644 --- a/lib/Lacuna/DB/Result/Promotion.pm +++ b/lib/Lacuna/DB/Result/Promotion.pm @@ -18,6 +18,8 @@ __PACKAGE__->add_columns( our @types = qw( Bonus50 + ECode50 + Valentine50 ); __PACKAGE__->typecast_map(type => { @@ -61,6 +63,7 @@ sub ui_details { end_date => format_date($self->end_date), type => $self->type, description => ucfirst $description, + title => $self->title }; } diff --git a/lib/Lacuna/DB/Result/Promotion/BonusEssentia.pm b/lib/Lacuna/DB/Result/Promotion/BonusEssentia.pm index 6e530998..eb90e808 100644 --- a/lib/Lacuna/DB/Result/Promotion/BonusEssentia.pm +++ b/lib/Lacuna/DB/Result/Promotion/BonusEssentia.pm @@ -6,6 +6,10 @@ no warnings qw(uninitialized); extends 'Lacuna::DB::Result::Promotion'; use constant category => 'essentia_purchase'; +sub title { + my ($self) = @_; + sprintf '%d%% Essentia Bonus', $self->bonus_percent; +} sub essentia_purchased { diff --git a/lib/Lacuna/DB/Result/Promotion/ECode50.pm b/lib/Lacuna/DB/Result/Promotion/ECode50.pm new file mode 100644 index 00000000..00c90c08 --- /dev/null +++ b/lib/Lacuna/DB/Result/Promotion/ECode50.pm @@ -0,0 +1,18 @@ +package Lacuna::DB::Result::Promotion::ECode50; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Promotion::EssentiaCode'; + +use constant title => '50% Essentia Code Bonus'; +use constant bonus_percent => 50; + +sub description { + my ($self) = @_; + + sprintf "receive an essentia code worth %d%% of your purchase that you can give to whomever you like!", $self->bonus_percent; +} + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Promotion/EssentiaCode.pm b/lib/Lacuna/DB/Result/Promotion/EssentiaCode.pm new file mode 100644 index 00000000..27aa0c02 --- /dev/null +++ b/lib/Lacuna/DB/Result/Promotion/EssentiaCode.pm @@ -0,0 +1,44 @@ +package Lacuna::DB::Result::Promotion::EssentiaCode; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Promotion'; +use UUID::Tiny ':std'; + +use constant category => 'essentia_purchase'; +sub title { + my ($self) = @_; + sprintf '%d%% Essentia Code Bonus', $self->bonus_percent; +} + +sub essentia_purchased +{ + my ($self, $opts) = @_; + + my $bonus = int( $opts->{amount} * $self->bonus_percent() / 10 + 0.5 ) / 10; + my $empire = $opts->{empire}; + + my $code = Lacuna->db->resultset('EssentiaCode')->new({ + date_created => DateTime->now, + amount => $bonus, + description => sprintf("Bonus Ecode for %s",$empire->name), + code => create_uuid_as_string(UUID_V4), + })->insert; + + $empire->send_predefined_message( + tags => ['Alert'], + filename => 'promo/essentia_code.txt', + params => [$self->bonus_percent(), $bonus, $code->code], + ); + +} + +sub description { + my ($self) = @_; + + sprintf "receive an essentia code worth %d%% of your purchase!", $self->bonus_percent; +} + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Promotion/Valentine50.pm b/lib/Lacuna/DB/Result/Promotion/Valentine50.pm new file mode 100644 index 00000000..e4b77e94 --- /dev/null +++ b/lib/Lacuna/DB/Result/Promotion/Valentine50.pm @@ -0,0 +1,17 @@ +package Lacuna::DB::Result::Promotion::Valentine50; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Promotion::ECode50'; + +use constant title => '50% Essentia Code Valentine Bonus'; + +sub description { + my ($self) = @_; + + sprintf "receive an essentia code worth %d%% of your purchase that you can give to your Valentine... or whomever you like!", $self->bonus_percent; +} + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/var/messages/promo/essentia_code.txt b/var/messages/promo/essentia_code.txt new file mode 100644 index 00000000..7835cd81 --- /dev/null +++ b/var/messages/promo/essentia_code.txt @@ -0,0 +1,9 @@ +Promotional Essentia Code +~~~ + +Due to the current %s%% bonus promotion, an {essentia} essentia code worth %s {essentia} has been created. You may use this code yourself, or you may give it to another player of your choosing. + +Code: %s + +Each code can only be redeemed once. +