Skip to content

Commit

Permalink
Merge pull request #34166 from KorGgenT/mutation-spell-fix
Browse files Browse the repository at this point in the history
fix mutations overriding spell level
  • Loading branch information
ZhilkinSerg authored Sep 22, 2019
2 parents d459981 + bfe7480 commit bc74033
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,11 @@ void spell::gain_exp( int nxp )
experience += nxp;
}

void spell::set_exp( int nxp )
{
experience = nxp;
}

std::string spell::energy_string() const
{
switch( type->energy_source ) {
Expand Down Expand Up @@ -1117,7 +1122,11 @@ void known_magic::deserialize( JsonIn &jsin )
std::string id = jo.get_string( "id" );
spell_id sp = spell_id( id );
int xp = jo.get_int( "xp" );
spellbook.emplace( sp, spell( sp, xp ) );
if( knows_spell( sp ) ) {
spellbook[sp].set_exp( xp );
} else {
spellbook.emplace( sp, spell( sp, xp ) );
}
}
}

Expand Down Expand Up @@ -1152,6 +1161,10 @@ void known_magic::learn_spell( const spell_type *sp, player &p, bool force )
debugmsg( "Tried to learn invalid spell" );
return;
}
if( p.magic.knows_spell( sp->id ) ) {
// you already know the spell
return;
}
spell temp_spell( sp->id );
if( !temp_spell.is_valid() ) {
debugmsg( "Tried to learn invalid spell" );
Expand Down
1 change: 1 addition & 0 deletions src/magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class spell
int xp() const;
// gain some exp
void gain_exp( int nxp );
void set_exp( int nxp );
// how much xp you get if you successfully cast the spell
int casting_exp( const player &p ) const;
// modifier for gaining exp
Expand Down

0 comments on commit bc74033

Please sign in to comment.