Compare commits

..

No commits in common. "5ea5d627bbc6a0e1077a8e71e6f841ade8c9b218" and "c42f13af52c749a5542046a350cb9819a156e1fc" have entirely different histories.

13 changed files with 242 additions and 762 deletions

View File

@ -57,47 +57,43 @@ message CofdSheet {
} }
string name = 1; string name = 1;
string gender = 2; string player = 2;
string concept = 3; string campaign = 3;
int32 age = 4; string description = 4;
string player = 5; int32 strength = 6;
string chronicle = 6; int32 dexterity = 7;
string description = 7; int32 stamina = 8;
int32 strength = 8; int32 intelligence = 9;
int32 dexterity = 9; int32 wits = 10;
int32 stamina = 10; int32 resolve = 11;
int32 intelligence = 11; int32 presence = 12;
int32 wits = 12; int32 manipulation = 13;
int32 resolve = 13; int32 composure = 14;
int32 presence = 14; map<string, Skill> physical_skills = 16;
int32 manipulation = 15; map<string, Skill> mental_skills = 17;
int32 composure = 16; map<string, Skill> social_skills = 18;
map<string, Skill> physical_skills = 17; repeated Merit merits = 15;
map<string, Skill> mental_skills = 18; repeated Condition conditions = 19;
map<string, Skill> social_skills = 19;
repeated Merit merits = 20; int32 size = 20;
repeated Condition conditions = 21; int32 health = 21;
int32 willpower = 22;
int32 experience_points = 23;
int32 beats = 24;
int32 size = 22; repeated Item items = 25;
int32 health = 23; repeated Attack attacks = 26;
int32 willpower = 24;
int32 experience_points = 25;
int32 beats = 26;
repeated Item items = 27; map<string, string> other_data = 27;
repeated Attack attacks = 28;
map<string, string> other_data = 29;
oneof system_fields { oneof system_fields {
CoreFields core = 30; CoreFields core = 28;
MageFields mage = 31; MageFields mage = 29;
ChangelingFields changeling = 32; ChangelingFields changeling = 30;
} }
} }

View File

@ -3,25 +3,15 @@ import "cofd.proto";
package models.proto.cofd.api; package models.proto.cofd.api;
message CharacterIdentifier {
string owner = 1;
int32 character_id = 2;
}
//Update basic information about a Chronicles of Darkness (or //Update basic information about a Chronicles of Darkness (or
//derivative system) character sheet. This is a straight overwrite of //derivative system) character sheet. This is a straight overwrite of
//all basic information on the sheet. //all basic information on the sheet.
message UpdateBasicInfoRequest { message UpdateBasicInfoRequest {
CharacterIdentifier id = 1; string name = 1;
reserved 2; string gender = 2;
// string owner = 1; string concept = 3;
// int32 character_id = 2; string chronicle = 4;
int32 age = 5;
string name = 3;
string gender = 4;
string concept = 5;
string chronicle = 6;
int32 age = 7;
} }
//Generic "did something succeed or not" response. //Generic "did something succeed or not" response.

View File

@ -39,8 +39,6 @@ pub(crate) trait Dao {
async fn insert_character(&self, new_character: NewCharacter<'_>) -> sqlx::Result<()>; async fn insert_character(&self, new_character: NewCharacter<'_>) -> sqlx::Result<()>;
async fn update_character<'a>(&self, character: &'a Character) -> sqlx::Result<()>;
async fn update_character_sheet<'a>(&self, character: &'a Character) -> sqlx::Result<()>; async fn update_character_sheet<'a>(&self, character: &'a Character) -> sqlx::Result<()>;
} }
@ -126,25 +124,6 @@ impl Dao for SqlitePool {
Ok(()) Ok(())
} }
async fn update_character<'a>(&self, character: &'a Character) -> sqlx::Result<()> {
sqlx::query(
"UPDATE characters
set user_id = ?, viewable = ?, character_name = ?,
data_type = ?, data_version = ?, data = ? where id = ?",
)
.bind(character.user_id)
.bind(character.viewable)
.bind(&character.character_name)
.bind(character.data_type)
.bind(character.data_version)
.bind(&character.data)
.bind(character.id)
.execute(self)
.await?;
Ok(())
}
async fn update_character_sheet<'a>(&self, character: &'a Character) -> sqlx::Result<()> { async fn update_character_sheet<'a>(&self, character: &'a Character) -> sqlx::Result<()> {
sqlx::query("UPDATE characters set data = ? where id = ?") sqlx::query("UPDATE characters set data = ? where id = ?")
.bind(&character.data) .bind(&character.data)

View File

@ -4,36 +4,7 @@
import * as jspb from "google-protobuf"; import * as jspb from "google-protobuf";
import * as cofd_pb from "./cofd_pb"; import * as cofd_pb from "./cofd_pb";
export class CharacterIdentifier extends jspb.Message {
getOwner(): string;
setOwner(value: string): void;
getCharacterId(): number;
setCharacterId(value: number): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): CharacterIdentifier.AsObject;
static toObject(includeInstance: boolean, msg: CharacterIdentifier): CharacterIdentifier.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: CharacterIdentifier, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): CharacterIdentifier;
static deserializeBinaryFromReader(message: CharacterIdentifier, reader: jspb.BinaryReader): CharacterIdentifier;
}
export namespace CharacterIdentifier {
export type AsObject = {
owner: string,
characterId: number,
}
}
export class UpdateBasicInfoRequest extends jspb.Message { export class UpdateBasicInfoRequest extends jspb.Message {
hasId(): boolean;
clearId(): void;
getId(): CharacterIdentifier | undefined;
setId(value?: CharacterIdentifier): void;
getName(): string; getName(): string;
setName(value: string): void; setName(value: string): void;
@ -61,7 +32,6 @@ export class UpdateBasicInfoRequest extends jspb.Message {
export namespace UpdateBasicInfoRequest { export namespace UpdateBasicInfoRequest {
export type AsObject = { export type AsObject = {
id?: CharacterIdentifier.AsObject,
name: string, name: string,
gender: string, gender: string,
concept: string, concept: string,

View File

@ -18,34 +18,12 @@ var cofd_pb = require('./cofd_pb.js');
goog.object.extend(proto, cofd_pb); goog.object.extend(proto, cofd_pb);
goog.exportSymbol('proto.models.proto.cofd.api.AddConditionRequest', null, global); goog.exportSymbol('proto.models.proto.cofd.api.AddConditionRequest', null, global);
goog.exportSymbol('proto.models.proto.cofd.api.ApiResult', null, global); goog.exportSymbol('proto.models.proto.cofd.api.ApiResult', null, global);
goog.exportSymbol('proto.models.proto.cofd.api.CharacterIdentifier', null, global);
goog.exportSymbol('proto.models.proto.cofd.api.RemoveConditionRequest', null, global); goog.exportSymbol('proto.models.proto.cofd.api.RemoveConditionRequest', null, global);
goog.exportSymbol('proto.models.proto.cofd.api.UpdateAttributeRequest', null, global); goog.exportSymbol('proto.models.proto.cofd.api.UpdateAttributeRequest', null, global);
goog.exportSymbol('proto.models.proto.cofd.api.UpdateBasicInfoRequest', null, global); goog.exportSymbol('proto.models.proto.cofd.api.UpdateBasicInfoRequest', null, global);
goog.exportSymbol('proto.models.proto.cofd.api.UpdateSkillRequest', null, global); goog.exportSymbol('proto.models.proto.cofd.api.UpdateSkillRequest', null, global);
goog.exportSymbol('proto.models.proto.cofd.api.UpdateSkillSpecializationsRequest', null, global); goog.exportSymbol('proto.models.proto.cofd.api.UpdateSkillSpecializationsRequest', null, global);
goog.exportSymbol('proto.models.proto.cofd.api.UpdateSkillValueRequest', null, global); goog.exportSymbol('proto.models.proto.cofd.api.UpdateSkillValueRequest', null, global);
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.models.proto.cofd.api.CharacterIdentifier = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.models.proto.cofd.api.CharacterIdentifier, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.models.proto.cofd.api.CharacterIdentifier.displayName = 'proto.models.proto.cofd.api.CharacterIdentifier';
}
/** /**
* Generated by JsPbCodeGenerator. * Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a * @param {Array=} opt_data Optional initial data array, typically from a
@ -217,166 +195,6 @@ if (goog.DEBUG && !COMPILED) {
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* Optional fields that are not set will be set to undefined.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
* JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @return {!Object}
*/
proto.models.proto.cofd.api.CharacterIdentifier.prototype.toObject = function(opt_includeInstance) {
return proto.models.proto.cofd.api.CharacterIdentifier.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
* the JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.models.proto.cofd.api.CharacterIdentifier} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.models.proto.cofd.api.CharacterIdentifier.toObject = function(includeInstance, msg) {
var f, obj = {
owner: jspb.Message.getFieldWithDefault(msg, 1, ""),
characterId: jspb.Message.getFieldWithDefault(msg, 2, 0)
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.models.proto.cofd.api.CharacterIdentifier}
*/
proto.models.proto.cofd.api.CharacterIdentifier.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.models.proto.cofd.api.CharacterIdentifier;
return proto.models.proto.cofd.api.CharacterIdentifier.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.models.proto.cofd.api.CharacterIdentifier} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.models.proto.cofd.api.CharacterIdentifier}
*/
proto.models.proto.cofd.api.CharacterIdentifier.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setOwner(value);
break;
case 2:
var value = /** @type {number} */ (reader.readInt32());
msg.setCharacterId(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.models.proto.cofd.api.CharacterIdentifier.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.models.proto.cofd.api.CharacterIdentifier.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.models.proto.cofd.api.CharacterIdentifier} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.models.proto.cofd.api.CharacterIdentifier.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getOwner();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
f = message.getCharacterId();
if (f !== 0) {
writer.writeInt32(
2,
f
);
}
};
/**
* optional string owner = 1;
* @return {string}
*/
proto.models.proto.cofd.api.CharacterIdentifier.prototype.getOwner = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/**
* @param {string} value
* @return {!proto.models.proto.cofd.api.CharacterIdentifier} returns this
*/
proto.models.proto.cofd.api.CharacterIdentifier.prototype.setOwner = function(value) {
return jspb.Message.setProto3StringField(this, 1, value);
};
/**
* optional int32 character_id = 2;
* @return {number}
*/
proto.models.proto.cofd.api.CharacterIdentifier.prototype.getCharacterId = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0));
};
/**
* @param {number} value
* @return {!proto.models.proto.cofd.api.CharacterIdentifier} returns this
*/
proto.models.proto.cofd.api.CharacterIdentifier.prototype.setCharacterId = function(value) {
return jspb.Message.setProto3IntField(this, 2, value);
};
if (jspb.Message.GENERATE_TO_OBJECT) { if (jspb.Message.GENERATE_TO_OBJECT) {
/** /**
* Creates an object representation of this proto. * Creates an object representation of this proto.
@ -406,12 +224,11 @@ proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.toObject = function
*/ */
proto.models.proto.cofd.api.UpdateBasicInfoRequest.toObject = function(includeInstance, msg) { proto.models.proto.cofd.api.UpdateBasicInfoRequest.toObject = function(includeInstance, msg) {
var f, obj = { var f, obj = {
id: (f = msg.getId()) && proto.models.proto.cofd.api.CharacterIdentifier.toObject(includeInstance, f), name: jspb.Message.getFieldWithDefault(msg, 1, ""),
name: jspb.Message.getFieldWithDefault(msg, 3, ""), gender: jspb.Message.getFieldWithDefault(msg, 2, ""),
gender: jspb.Message.getFieldWithDefault(msg, 4, ""), concept: jspb.Message.getFieldWithDefault(msg, 3, ""),
concept: jspb.Message.getFieldWithDefault(msg, 5, ""), chronicle: jspb.Message.getFieldWithDefault(msg, 4, ""),
chronicle: jspb.Message.getFieldWithDefault(msg, 6, ""), age: jspb.Message.getFieldWithDefault(msg, 5, 0)
age: jspb.Message.getFieldWithDefault(msg, 7, 0)
}; };
if (includeInstance) { if (includeInstance) {
@ -449,27 +266,22 @@ proto.models.proto.cofd.api.UpdateBasicInfoRequest.deserializeBinaryFromReader =
var field = reader.getFieldNumber(); var field = reader.getFieldNumber();
switch (field) { switch (field) {
case 1: case 1:
var value = new proto.models.proto.cofd.api.CharacterIdentifier;
reader.readMessage(value,proto.models.proto.cofd.api.CharacterIdentifier.deserializeBinaryFromReader);
msg.setId(value);
break;
case 3:
var value = /** @type {string} */ (reader.readString()); var value = /** @type {string} */ (reader.readString());
msg.setName(value); msg.setName(value);
break; break;
case 4: case 2:
var value = /** @type {string} */ (reader.readString()); var value = /** @type {string} */ (reader.readString());
msg.setGender(value); msg.setGender(value);
break; break;
case 5: case 3:
var value = /** @type {string} */ (reader.readString()); var value = /** @type {string} */ (reader.readString());
msg.setConcept(value); msg.setConcept(value);
break; break;
case 6: case 4:
var value = /** @type {string} */ (reader.readString()); var value = /** @type {string} */ (reader.readString());
msg.setChronicle(value); msg.setChronicle(value);
break; break;
case 7: case 5:
var value = /** @type {number} */ (reader.readInt32()); var value = /** @type {number} */ (reader.readInt32());
msg.setAge(value); msg.setAge(value);
break; break;
@ -502,46 +314,38 @@ proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.serializeBinary = f
*/ */
proto.models.proto.cofd.api.UpdateBasicInfoRequest.serializeBinaryToWriter = function(message, writer) { proto.models.proto.cofd.api.UpdateBasicInfoRequest.serializeBinaryToWriter = function(message, writer) {
var f = undefined; var f = undefined;
f = message.getId();
if (f != null) {
writer.writeMessage(
1,
f,
proto.models.proto.cofd.api.CharacterIdentifier.serializeBinaryToWriter
);
}
f = message.getName(); f = message.getName();
if (f.length > 0) { if (f.length > 0) {
writer.writeString( writer.writeString(
3, 1,
f f
); );
} }
f = message.getGender(); f = message.getGender();
if (f.length > 0) { if (f.length > 0) {
writer.writeString( writer.writeString(
4, 2,
f f
); );
} }
f = message.getConcept(); f = message.getConcept();
if (f.length > 0) { if (f.length > 0) {
writer.writeString( writer.writeString(
5, 3,
f f
); );
} }
f = message.getChronicle(); f = message.getChronicle();
if (f.length > 0) { if (f.length > 0) {
writer.writeString( writer.writeString(
6, 4,
f f
); );
} }
f = message.getAge(); f = message.getAge();
if (f !== 0) { if (f !== 0) {
writer.writeInt32( writer.writeInt32(
7, 5,
f f
); );
} }
@ -549,48 +353,11 @@ proto.models.proto.cofd.api.UpdateBasicInfoRequest.serializeBinaryToWriter = fun
/** /**
* optional CharacterIdentifier id = 1; * optional string name = 1;
* @return {?proto.models.proto.cofd.api.CharacterIdentifier}
*/
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getId = function() {
return /** @type{?proto.models.proto.cofd.api.CharacterIdentifier} */ (
jspb.Message.getWrapperField(this, proto.models.proto.cofd.api.CharacterIdentifier, 1));
};
/**
* @param {?proto.models.proto.cofd.api.CharacterIdentifier|undefined} value
* @return {!proto.models.proto.cofd.api.UpdateBasicInfoRequest} returns this
*/
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.setId = function(value) {
return jspb.Message.setWrapperField(this, 1, value);
};
/**
* Clears the message field making it undefined.
* @return {!proto.models.proto.cofd.api.UpdateBasicInfoRequest} returns this
*/
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.clearId = function() {
return this.setId(undefined);
};
/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.hasId = function() {
return jspb.Message.getField(this, 1) != null;
};
/**
* optional string name = 3;
* @return {string} * @return {string}
*/ */
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getName = function() { proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getName = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
}; };
@ -599,16 +366,16 @@ proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getName = function(
* @return {!proto.models.proto.cofd.api.UpdateBasicInfoRequest} returns this * @return {!proto.models.proto.cofd.api.UpdateBasicInfoRequest} returns this
*/ */
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.setName = function(value) { proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.setName = function(value) {
return jspb.Message.setProto3StringField(this, 3, value); return jspb.Message.setProto3StringField(this, 1, value);
}; };
/** /**
* optional string gender = 4; * optional string gender = 2;
* @return {string} * @return {string}
*/ */
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getGender = function() { proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getGender = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
}; };
@ -617,16 +384,16 @@ proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getGender = functio
* @return {!proto.models.proto.cofd.api.UpdateBasicInfoRequest} returns this * @return {!proto.models.proto.cofd.api.UpdateBasicInfoRequest} returns this
*/ */
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.setGender = function(value) { proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.setGender = function(value) {
return jspb.Message.setProto3StringField(this, 4, value); return jspb.Message.setProto3StringField(this, 2, value);
}; };
/** /**
* optional string concept = 5; * optional string concept = 3;
* @return {string} * @return {string}
*/ */
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getConcept = function() { proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getConcept = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
}; };
@ -635,16 +402,16 @@ proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getConcept = functi
* @return {!proto.models.proto.cofd.api.UpdateBasicInfoRequest} returns this * @return {!proto.models.proto.cofd.api.UpdateBasicInfoRequest} returns this
*/ */
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.setConcept = function(value) { proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.setConcept = function(value) {
return jspb.Message.setProto3StringField(this, 5, value); return jspb.Message.setProto3StringField(this, 3, value);
}; };
/** /**
* optional string chronicle = 6; * optional string chronicle = 4;
* @return {string} * @return {string}
*/ */
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getChronicle = function() { proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getChronicle = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, ""));
}; };
@ -653,16 +420,16 @@ proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getChronicle = func
* @return {!proto.models.proto.cofd.api.UpdateBasicInfoRequest} returns this * @return {!proto.models.proto.cofd.api.UpdateBasicInfoRequest} returns this
*/ */
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.setChronicle = function(value) { proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.setChronicle = function(value) {
return jspb.Message.setProto3StringField(this, 6, value); return jspb.Message.setProto3StringField(this, 4, value);
}; };
/** /**
* optional int32 age = 7; * optional int32 age = 5;
* @return {number} * @return {number}
*/ */
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getAge = function() { proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getAge = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 7, 0)); return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0));
}; };
@ -671,7 +438,7 @@ proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.getAge = function()
* @return {!proto.models.proto.cofd.api.UpdateBasicInfoRequest} returns this * @return {!proto.models.proto.cofd.api.UpdateBasicInfoRequest} returns this
*/ */
proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.setAge = function(value) { proto.models.proto.cofd.api.UpdateBasicInfoRequest.prototype.setAge = function(value) {
return jspb.Message.setProto3IntField(this, 7, value); return jspb.Message.setProto3IntField(this, 5, value);
}; };

View File

@ -67,20 +67,11 @@ export class CofdSheet extends jspb.Message {
getName(): string; getName(): string;
setName(value: string): void; setName(value: string): void;
getGender(): string;
setGender(value: string): void;
getConcept(): string;
setConcept(value: string): void;
getAge(): number;
setAge(value: number): void;
getPlayer(): string; getPlayer(): string;
setPlayer(value: string): void; setPlayer(value: string): void;
getChronicle(): string; getCampaign(): string;
setChronicle(value: string): void; setCampaign(value: string): void;
getDescription(): string; getDescription(): string;
setDescription(value: string): void; setDescription(value: string): void;
@ -184,11 +175,8 @@ export class CofdSheet extends jspb.Message {
export namespace CofdSheet { export namespace CofdSheet {
export type AsObject = { export type AsObject = {
name: string, name: string,
gender: string,
concept: string,
age: number,
player: string, player: string,
chronicle: string, campaign: string,
description: string, description: string,
strength: number, strength: number,
dexterity: number, dexterity: number,
@ -365,9 +353,9 @@ export namespace CofdSheet {
export enum SystemFieldsCase { export enum SystemFieldsCase {
SYSTEM_FIELDS_NOT_SET = 0, SYSTEM_FIELDS_NOT_SET = 0,
CORE = 30, CORE = 28,
MAGE = 31, MAGE = 29,
CHANGELING = 32, CHANGELING = 30,
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
import * as jspb from "google-protobuf"; import * as jspb from "google-protobuf";
import { ApiResult, UpdateBasicInfoRequest, UpdateAttributeRequest, UpdateSkillValueRequest } from "../_proto/cofd_api_pb"; import { ApiResult, UpdateAttributeRequest, UpdateSkillValueRequest } from "../_proto/cofd_api_pb";
const PROTOBUF_CONTENT_TYPE = { 'Content-Type': 'application/x-protobuf' }; const PROTOBUF_CONTENT_TYPE = { 'Content-Type': 'application/x-protobuf' };
@ -7,6 +7,7 @@ function staticImplements<T>() {
return <U extends T>(constructor: U) => { constructor }; return <U extends T>(constructor: U) => { constructor };
} }
async function makeRequest<T extends jspb.Message>(uri: string, params: T): Promise<Uint8Array> { async function makeRequest<T extends jspb.Message>(uri: string, params: T): Promise<Uint8Array> {
let resp = await fetch(uri, { let resp = await fetch(uri, {
method: 'POST', method: 'POST',
@ -27,8 +28,3 @@ export async function updateAttributeValue(params: UpdateAttributeRequest): Prom
let data = await makeRequest('/api/rpc/cofd/update_attribute_value', params); let data = await makeRequest('/api/rpc/cofd/update_attribute_value', params);
return ApiResult.deserializeBinary(data); return ApiResult.deserializeBinary(data);
} }
export async function updateBasicInfo(params: UpdateBasicInfoRequest): Promise<ApiResult> {
let data = await makeRequest('/api/rpc/cofd/update_basic_info', params);
return ApiResult.deserializeBinary(data);
}

View File

@ -1,4 +1,4 @@
import { CharacterIdentifier, UpdateBasicInfoRequest, UpdateSkillValueRequest, UpdateAttributeRequest } from "../../_proto/cofd_api_pb"; import { UpdateSkillValueRequest, UpdateAttributeRequest } from "../../_proto/cofd_api_pb";
import * as api from "../api"; import * as api from "../api";
// This is the scripting for the edit character page, which submits // This is the scripting for the edit character page, which submits
@ -10,19 +10,6 @@ import * as api from "../api";
const [, , USERNAME, CHARACTER_ID] = window.location.pathname.split('/'); const [, , USERNAME, CHARACTER_ID] = window.location.pathname.split('/');
function characterId(): CharacterIdentifier {
const id = new CharacterIdentifier();
id.setCharacterId(parseInt(CHARACTER_ID));
id.setOwner(USERNAME);
return id;
}
const getTextValue = (selector: string) =>
document.querySelector<HTMLInputElement>(selector)?.value ?? "";
const getIntValue = (selector: string) =>
parseInt(document.querySelector<HTMLInputElement>(selector)?.value ?? "0")
function setupAttributes() { function setupAttributes() {
const attributeInputs = document.querySelectorAll('#attributes input[type="number"]'); const attributeInputs = document.querySelectorAll('#attributes input[type="number"]');
@ -65,6 +52,7 @@ import * as api from "../api";
params.setSkillValue(newValue); params.setSkillValue(newValue);
let resp = await api.updateSkillValue(params); let resp = await api.updateSkillValue(params);
console.log("got a response back", resp); console.log("got a response back", resp);
} }
@ -73,32 +61,8 @@ import * as api from "../api";
}); });
} }
function setupBasicInfo() {
async function updateInfo() {
const params = new UpdateBasicInfoRequest();
params.setId(characterId());
params.setName(getTextValue("#characterName"));
params.setAge(getIntValue("#age"));
params.setConcept(getTextValue("#concept"));
params.setChronicle(getTextValue("#chronicle"));
params.setGender(getTextValue("#gender"));
let resp = await api.updateBasicInfo(params);
console.log("got a response back", resp);
}
const inputs = document.querySelectorAll("#basicInfo input");
inputs.forEach(input => {
console.log('got an input', input);
input.addEventListener('blur', updateInfo);
});
}
setupAttributes(); setupAttributes();
setupSkills(); setupSkills();
setupBasicInfo();
})().catch(e => { })().catch(e => {
alert(e); alert(e);
}); });

View File

@ -89,34 +89,8 @@
<h1>Core Sheet</h1> <h1>Core Sheet</h1>
<div> <div>
<div id="basicInfo"> <h1>Name: <input type="text" value="{{name}}" /></h1>
<h1> <p>System: {{data_type}}</p>
<label for="characterName">Name:</label>
<input type="text" id="characterName" name="characterName" value="{{name}}" />
</h1>
<div>System: {{data_type}}</div>
<div>
<label for="gender">Gender:</label>
<input type="text" id="gender" name="gender" value="{{sheet.gender}}" />
</div>
<div>
<label for="age">Age:</label>
<input type="number" id="age" name="age" min="0" value="{{sheet.age}}" />
</div>
<div>
<label for="concept">Concept:</label>
<input type="text" id="concept" name="concept" value="{{sheet.concept}}" />
</div>
<div>
<label for="chronicle">Chronicle:</label>
<input type="text" id="chronicle" name="chronicle" value="{{sheet.chronicle}}" />
</div>
</div>
<div id="attributes"> <div id="attributes">
<div class="attributes-section" id="mentalAttributes"> <div class="attributes-section" id="mentalAttributes">
{{ macros::attribute(name="Intelligence", value=sheet.intelligence) }} {{ macros::attribute(name="Intelligence", value=sheet.intelligence) }}

View File

@ -7,7 +7,7 @@ use rocket::response::status;
use rocket::response::{self, Responder, Response}; use rocket::response::{self, Responder, Response};
use std::default::Default; use std::default::Default;
use std::io::Cursor; use std::io::Cursor;
use std::ops::{Deref, DerefMut}; use std::ops::Deref;
pub mod cofd; pub mod cofd;
@ -79,12 +79,3 @@ where
&self.0 &self.0
} }
} }
impl<T> DerefMut for Proto<T>
where
T: prost::Message + Default,
{
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}

View File

@ -13,31 +13,6 @@ tonic::include_proto!("models.proto.cofd");
pub mod api { pub mod api {
//include!(concat!(env!("OUT_DIR"), "/models.proto.cofd.api.rs")); //include!(concat!(env!("OUT_DIR"), "/models.proto.cofd.api.rs"));
tonic::include_proto!("models.proto.cofd.api"); tonic::include_proto!("models.proto.cofd.api");
/// Trait to extract CharacterIdentifier while avoiding clone. The
/// character identifier is extracted out of the Option, leaving
/// None in its place.
pub trait DefaultCharacterIdentifier {
/// Extract the CharacterIdentifier from the containing type,
/// leaving behind a default value.
fn or_default(&mut self) -> CharacterIdentifier;
}
impl DefaultCharacterIdentifier for Option<CharacterIdentifier> {
fn or_default(&mut self) -> CharacterIdentifier {
self.take().unwrap_or_default()
}
}
/// Helpers for the ApiResult class.
impl ApiResult {
pub fn success() -> Self {
ApiResult {
success: true,
error: "".to_string(),
}
}
}
} }
/// Default mental skill names for a regular Chronicles of Darkness /// Default mental skill names for a regular Chronicles of Darkness

View File

@ -2,7 +2,6 @@ use super::load_character;
use crate::db::{Dao, TenebrousDbConn}; use crate::db::{Dao, TenebrousDbConn};
use crate::errors::Error; use crate::errors::Error;
use crate::models::characters::Character; use crate::models::characters::Character;
use crate::models::proto::cofd::api::DefaultCharacterIdentifier;
use crate::models::proto::cofd::cofd_sheet::Skill; use crate::models::proto::cofd::cofd_sheet::Skill;
use crate::models::proto::cofd::*; use crate::models::proto::cofd::*;
use crate::models::proto::{cofd::api::*, cofd::*, Proto}; use crate::models::proto::{cofd::api::*, cofd::*, Proto};
@ -38,28 +37,9 @@ fn find_skill<'a>(sheet: &'a mut CofdSheet, skill_name: &'a str) -> Option<&'a m
find_skill_entry(sheet, skill_name).map(|entry| entry.into_mut()) find_skill_entry(sheet, skill_name).map(|entry| entry.into_mut())
} }
#[post("/rpc/cofd/update_basic_info", data = "<req>")] #[post("/rpc/cofd/update_basic_info", data = "<info>")]
pub(super) async fn update_basic_info<'a>( pub(super) fn update_basic_info<'a>(info: Proto<UpdateBasicInfoRequest>) -> &'a str {
mut req: Proto<UpdateBasicInfoRequest>, "lol"
conn: TenebrousDbConn<'_>,
logged_in_user: Option<&User>,
) -> Result<Proto<ApiResult>, Error> {
let id = req.id.or_default();
let mut character = load_character(&conn, logged_in_user, &id.owner, id.character_id).await?;
let mut sheet: CofdSheet = character.try_deserialize()?;
println!("name will now be {}", req.name);
character.character_name = req.name.clone(); //Should probably remove name from the sheet?
sheet.name = req.name.clone();
sheet.gender = req.gender.clone();
sheet.concept = req.concept.clone();
sheet.chronicle = req.chronicle.clone();
sheet.age = req.age;
character.update_data(&sheet)?;
conn.update_character(&character).await?;
println!("Updated basic info");
Ok(Proto(ApiResult::success()))
} }
#[post("/rpc/cofd/update_attribute_value", data = "<req>")] #[post("/rpc/cofd/update_attribute_value", data = "<req>")]