forked from runuo/runuo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVirtueInfo.cs
147 lines (117 loc) · 3.9 KB
/
VirtueInfo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/***************************************************************************
* VirtueInfo.cs
* -------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : [email protected]
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
using System;
namespace Server
{
[PropertyObject]
public class VirtueInfo
{
private int[] m_Values;
public int[] Values
{
get
{
return m_Values;
}
}
public int GetValue( int index )
{
if ( m_Values == null )
return 0;
else
return m_Values[index];
}
public void SetValue( int index, int value )
{
if ( m_Values == null )
m_Values = new int[8];
m_Values[index] = value;
}
public override string ToString()
{
return "...";
}
[CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
public int Humility{ get{ return GetValue( 0 ); } set{ SetValue( 0, value ); } }
[CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
public int Sacrifice{ get{ return GetValue( 1 ); } set{ SetValue( 1, value ); } }
[CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
public int Compassion{ get{ return GetValue( 2 ); } set{ SetValue( 2, value ); } }
[CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
public int Spirituality{ get{ return GetValue( 3 ); } set{ SetValue( 3, value ); } }
[CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
public int Valor{ get{ return GetValue( 4 ); } set{ SetValue( 4, value ); } }
[CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
public int Honor{ get{ return GetValue( 5 ); } set{ SetValue( 5, value ); } }
[CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
public int Justice{ get{ return GetValue( 6 ); } set{ SetValue( 6, value ); } }
[CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
public int Honesty{ get{ return GetValue( 7 ); } set{ SetValue( 7, value ); } }
public VirtueInfo()
{
}
public VirtueInfo( GenericReader reader )
{
int version = reader.ReadByte();
switch ( version )
{
case 1: //Changed the values throughout the virtue system
case 0:
{
int mask = reader.ReadByte();
if ( mask != 0 )
{
m_Values = new int[8];
for ( int i = 0; i < 8; ++i )
if ( (mask & (1 << i)) != 0 )
m_Values[i] = reader.ReadInt();
}
break;
}
}
if( version == 0 )
{
Compassion *= 200;
Sacrifice *= 250; //Even though 40 (the max) only gives 10k, It's because it was formerly too easy
//No direct conversion factor for Justice, this is just an approximation
Justice *= 500;
//All the other virtues haven't been defined at 'version 0' point in time in the scripts.
}
}
public static void Serialize( GenericWriter writer, VirtueInfo info )
{
writer.Write( (byte) 1 ); // version
if ( info.m_Values == null )
{
writer.Write( (byte) 0 );
}
else
{
int mask = 0;
for ( int i = 0; i < 8; ++i )
if ( info.m_Values[i] != 0 )
mask |= 1 << i;
writer.Write( (byte) mask );
for ( int i = 0; i < 8; ++i )
if ( info.m_Values[i] != 0 )
writer.Write( (int) info.m_Values[i] );
}
}
}
}