… | |
… | |
673 | my ($self, $thing) = @_; |
673 | my ($self, $thing) = @_; |
674 | |
674 | |
675 | my $obj = {}; |
675 | my $obj = {}; |
676 | |
676 | |
677 | for (@Jeweler::RESISTS) { |
677 | for (@Jeweler::RESISTS) { |
678 | $obj->{resist}->{$_} = $thing->get_resistance ($_); |
678 | $obj->{resist}->{$_} = $thing->resistance ($_); |
679 | } |
679 | } |
680 | |
680 | |
681 | my $stats = $thing->stats; |
681 | my $stats = $thing->stats; |
682 | |
682 | |
683 | for (qw/Str Dex Con Wis Cha Int Pow/) { |
683 | for (qw/Str Dex Con Wis Cha Int Pow/) { |
684 | $obj->{stat}->{lc $_} = $stats->$_; |
684 | $obj->{stat}->{lc $_} = $stats->$_; |
685 | } |
685 | } |
686 | |
686 | |
687 | $obj->{spec}->{regen} = $thing->hp; |
687 | $obj->{spec}{regen} = $stats->hp; |
688 | $obj->{spec}->{magic} = $thing->sp; |
688 | $obj->{spec}{magic} = $stats->sp; |
689 | $obj->{spec}->{wc} = $thing->wc; |
689 | $obj->{spec}{wc} = $stats->wc; |
690 | $obj->{spec}->{dam} = $thing->dam; |
690 | $obj->{spec}{dam} = $stats->dam; |
691 | $obj->{spec}->{ac} = $thing->ac; |
691 | $obj->{spec}{ac} = $stats->ac; |
692 | $obj->{spec}->{speed} = $thing->stats->exp; |
692 | $obj->{spec}{speed} = $stats->exp; |
693 | $obj->{spec}->{suste} = $thing->food; |
693 | $obj->{spec}{food} = $stats->food; |
694 | |
694 | |
695 | $obj->{name} = $thing->name; |
695 | $obj->{name} = $thing->name; |
696 | $obj->{arch} = $thing->archetype->name; |
696 | $obj->{arch} = $thing->archetype->name; |
697 | $obj->{face} = $thing->face; |
697 | $obj->{face} = $thing->face; |
698 | |
698 | |
699 | $self->{hash} = $obj |
699 | $self->{hash} = $obj |
700 | } |
700 | } |
701 | |
701 | |
702 | sub to_object { |
702 | sub to_object { |
703 | my ($self) = @_; |
703 | my ($self) = @_; |
|
|
704 | |
704 | my $obj = cf::object::new $self->{hash}->{arch}; |
705 | my $obj = cf::object::new $self->{hash}->{arch}; |
|
|
706 | |
705 | $obj->set_face ($self->{hash}->{face}); |
707 | $obj->face ($self->{hash}{face}); |
706 | |
708 | |
|
|
709 | my $stats = $obj->stats; |
|
|
710 | |
707 | $obj->set_hp ($self->{hash}->{spec}->{regen} * 1); |
711 | $stats->hp ($self->{hash}{spec}{regen}); |
708 | $obj->set_sp ($self->{hash}->{spec}->{magic} * 1); |
712 | $stats->sp ($self->{hash}{spec}{magic}); |
709 | $obj->set_wc ($self->{hash}->{spec}->{wc} * 1); |
713 | $stats->wc ($self->{hash}{spec}{wc}); |
710 | $obj->set_dam ($self->{hash}->{spec}->{dam} * 1); |
714 | $stats->dam ($self->{hash}{spec}{dam}); |
711 | $obj->set_ac ($self->{hash}->{spec}->{ac} * 1); |
715 | $stats->ac ($self->{hash}{spec}{ac}); |
712 | $obj->stats->exp ($self->{hash}->{spec}->{speed} * 1); |
716 | $stats->exp ($self->{hash}{spec}{speed}); |
713 | $obj->set_food ($self->{hash}->{spec}->{suste} * 1); |
717 | $stats->food ($self->{hash}{spec}{food}); |
714 | |
718 | |
|
|
719 | $stats->$_ ($self->{hash}{stat}{lc $_}) |
715 | for (qw/Str Dex Con Wis Cha Int Pow/) { |
720 | for qw/Str Dex Con Wis Cha Int Pow/; |
716 | $obj->stats->$_ ($self->{hash}->{stat}->{lc $_} * 1); |
|
|
717 | } |
|
|
718 | |
721 | |
719 | for (@Jeweler::RESISTS) { |
722 | for (@Jeweler::RESISTS) { |
720 | $obj->set_resistance ($_, $self->{hash}->{resist}->{$_} * 1); |
723 | $obj->resistance ($_, $self->{hash}->{resist}->{$_}); |
721 | } |
724 | } |
722 | |
725 | |
723 | $obj->flag (cf::FLAG_IDENTIFIED, 1); |
726 | $obj->flag (cf::FLAG_IDENTIFIED, 1); |
724 | |
727 | |
725 | return $obj; |
728 | return $obj; |
… | |
… | |
907 | my $sum = sum (@$stat_split); |
910 | my $sum = sum (@$stat_split); |
908 | if ($sum < (1 - 0.0001)) { |
911 | if ($sum < (1 - 0.0001)) { |
909 | warn "JEWELER BUG: sum (@$stat_split) = $sum < 1 for $category!"; |
912 | warn "JEWELER BUG: sum (@$stat_split) = $sum < 1 for $category!"; |
910 | } |
913 | } |
911 | |
914 | |
912 | my $emarch = cf::arch::find ('emerald'); |
915 | my $emarch = cf::arch::find 'emerald'; |
913 | my $saarch = cf::arch::find ('sapphire'); |
916 | my $saarch = cf::arch::find 'sapphire'; |
914 | my $pearch = cf::arch::find ('pearl'); |
917 | my $pearch = cf::arch::find 'pearl'; |
915 | my $ruarch = cf::arch::find ('ruby'); |
918 | my $ruarch = cf::arch::find 'ruby'; |
916 | my $diarch = cf::arch::find ('gem'); |
919 | my $diarch = cf::arch::find 'gem'; |
917 | |
920 | |
918 | my $sumvalue = $diarch->clone->value * $diamonds; |
921 | my $sumvalue = $diarch->clone->value * $diamonds; |
919 | |
922 | |
920 | $cost->{emerald} += ceil (($sumvalue * $stat_split->[0]) / max (1, $emarch->clone->value)); |
923 | $cost->{emerald} += ceil $sumvalue * $stat_split->[0] / max 1, $emarch->clone->value; |
921 | $cost->{sapphire} += ceil (($sumvalue * $stat_split->[1]) / max (1, $saarch->clone->value)); |
924 | $cost->{sapphire} += ceil $sumvalue * $stat_split->[1] / max 1, $saarch->clone->value; |
922 | $cost->{pearl} += ceil (($sumvalue * $stat_split->[2]) / max (1, $pearch->clone->value)); |
925 | $cost->{pearl} += ceil $sumvalue * $stat_split->[2] / max 1, $pearch->clone->value; |
923 | $cost->{ruby} += ceil (($sumvalue * $stat_split->[3]) / max (1, $ruarch->clone->value)); |
926 | $cost->{ruby} += ceil $sumvalue * $stat_split->[3] / max 1, $ruarch->clone->value; |
924 | $cost->{gem} += ceil (($sumvalue * $stat_split->[4]) / max (1, $diarch->clone->value)); |
927 | $cost->{gem} += ceil $sumvalue * $stat_split->[4] / max 1, $diarch->clone->value; |
925 | } |
928 | } |
926 | |
929 | |
927 | |
930 | |
928 | |
931 | |
929 | package Jeweler::Util; |
932 | package Jeweler::Util; |
… | |
… | |
950 | if (defined $nrof) { |
953 | if (defined $nrof) { |
951 | return 0 if ($nrof * 1) == 0; |
954 | return 0 if ($nrof * 1) == 0; |
952 | $cnt = int (($obj->nrof || 1) - (1 * $nrof)); |
955 | $cnt = int (($obj->nrof || 1) - (1 * $nrof)); |
953 | |
956 | |
954 | if ($cnt > 0) { |
957 | if ($cnt > 0) { |
955 | $obj->set_nrof ($cnt); |
958 | $obj->nrof ($cnt); |
956 | return 0; |
959 | return 0; |
957 | } |
960 | } |
958 | } |
961 | } |
959 | |
962 | |
960 | remove ($_) for ($obj->inv); |
963 | remove ($_) for $obj->inv; |
961 | $obj->remove; |
964 | $obj->remove; |
962 | $obj->free; |
965 | $obj->free; |
963 | return $cnt; |
966 | return $cnt; |
964 | } |
967 | } |
965 | |
968 | |