Clean up files and remove things that no longer need to exist.
This commit is contained in:
parent
a729ccb4a2
commit
b3253922df
|
@ -1,8 +1,6 @@
|
||||||
{% extends "base" %}
|
{% extends "base" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<script src="https://cdn.jsdelivr.net/npm/protobufjs@6.10.2/dist/protobuf.min.js"></script>
|
|
||||||
<script type="text/javascript" src="/scripts/characters/new-character.js"></script>
|
|
||||||
<div>
|
<div>
|
||||||
New character page.
|
New character page.
|
||||||
|
|
||||||
|
|
|
@ -1,64 +1,3 @@
|
||||||
// package: models.proto.cofd.api
|
// package: models.proto.cofd.api
|
||||||
// file: cofd_api.proto
|
// file: cofd_api.proto
|
||||||
|
|
||||||
import * as cofd_api_pb from "./cofd_api_pb";
|
|
||||||
import * as cofd_pb from "./cofd_pb";
|
|
||||||
import {grpc} from "@improbable-eng/grpc-web";
|
|
||||||
|
|
||||||
type CofdApiUpdateSkillValue = {
|
|
||||||
readonly methodName: string;
|
|
||||||
readonly service: typeof CofdApi;
|
|
||||||
readonly requestStream: false;
|
|
||||||
readonly responseStream: false;
|
|
||||||
readonly requestType: typeof cofd_api_pb.UpdateSkillValueRequest;
|
|
||||||
readonly responseType: typeof cofd_pb.CofdSheet.Skill;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class CofdApi {
|
|
||||||
static readonly serviceName: string;
|
|
||||||
static readonly UpdateSkillValue: CofdApiUpdateSkillValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ServiceError = { message: string, code: number; metadata: grpc.Metadata }
|
|
||||||
export type Status = { details: string, code: number; metadata: grpc.Metadata }
|
|
||||||
|
|
||||||
interface UnaryResponse {
|
|
||||||
cancel(): void;
|
|
||||||
}
|
|
||||||
interface ResponseStream<T> {
|
|
||||||
cancel(): void;
|
|
||||||
on(type: 'data', handler: (message: T) => void): ResponseStream<T>;
|
|
||||||
on(type: 'end', handler: (status?: Status) => void): ResponseStream<T>;
|
|
||||||
on(type: 'status', handler: (status: Status) => void): ResponseStream<T>;
|
|
||||||
}
|
|
||||||
interface RequestStream<T> {
|
|
||||||
write(message: T): RequestStream<T>;
|
|
||||||
end(): void;
|
|
||||||
cancel(): void;
|
|
||||||
on(type: 'end', handler: (status?: Status) => void): RequestStream<T>;
|
|
||||||
on(type: 'status', handler: (status: Status) => void): RequestStream<T>;
|
|
||||||
}
|
|
||||||
interface BidirectionalStream<ReqT, ResT> {
|
|
||||||
write(message: ReqT): BidirectionalStream<ReqT, ResT>;
|
|
||||||
end(): void;
|
|
||||||
cancel(): void;
|
|
||||||
on(type: 'data', handler: (message: ResT) => void): BidirectionalStream<ReqT, ResT>;
|
|
||||||
on(type: 'end', handler: (status?: Status) => void): BidirectionalStream<ReqT, ResT>;
|
|
||||||
on(type: 'status', handler: (status: Status) => void): BidirectionalStream<ReqT, ResT>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CofdApiClient {
|
|
||||||
readonly serviceHost: string;
|
|
||||||
|
|
||||||
constructor(serviceHost: string, options?: grpc.RpcOptions);
|
|
||||||
updateSkillValue(
|
|
||||||
requestMessage: cofd_api_pb.UpdateSkillValueRequest,
|
|
||||||
metadata: grpc.Metadata,
|
|
||||||
callback: (error: ServiceError|null, responseMessage: cofd_pb.CofdSheet.Skill|null) => void
|
|
||||||
): UnaryResponse;
|
|
||||||
updateSkillValue(
|
|
||||||
requestMessage: cofd_api_pb.UpdateSkillValueRequest,
|
|
||||||
callback: (error: ServiceError|null, responseMessage: cofd_pb.CofdSheet.Skill|null) => void
|
|
||||||
): UnaryResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,62 +1,3 @@
|
||||||
// package: models.proto.cofd.api
|
// package: models.proto.cofd.api
|
||||||
// file: cofd_api.proto
|
// file: cofd_api.proto
|
||||||
|
|
||||||
var cofd_api_pb = require("./cofd_api_pb");
|
|
||||||
var cofd_pb = require("./cofd_pb");
|
|
||||||
var grpc = require("@improbable-eng/grpc-web").grpc;
|
|
||||||
|
|
||||||
var CofdApi = (function () {
|
|
||||||
function CofdApi() {}
|
|
||||||
CofdApi.serviceName = "models.proto.cofd.api.CofdApi";
|
|
||||||
return CofdApi;
|
|
||||||
}());
|
|
||||||
|
|
||||||
CofdApi.UpdateSkillValue = {
|
|
||||||
methodName: "UpdateSkillValue",
|
|
||||||
service: CofdApi,
|
|
||||||
requestStream: false,
|
|
||||||
responseStream: false,
|
|
||||||
requestType: cofd_api_pb.UpdateSkillValueRequest,
|
|
||||||
responseType: cofd_pb.CofdSheet.Skill
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.CofdApi = CofdApi;
|
|
||||||
|
|
||||||
function CofdApiClient(serviceHost, options) {
|
|
||||||
this.serviceHost = serviceHost;
|
|
||||||
this.options = options || {};
|
|
||||||
}
|
|
||||||
|
|
||||||
CofdApiClient.prototype.updateSkillValue = function updateSkillValue(requestMessage, metadata, callback) {
|
|
||||||
if (arguments.length === 2) {
|
|
||||||
callback = arguments[1];
|
|
||||||
}
|
|
||||||
var client = grpc.unary(CofdApi.UpdateSkillValue, {
|
|
||||||
request: requestMessage,
|
|
||||||
host: this.serviceHost,
|
|
||||||
metadata: metadata,
|
|
||||||
transport: this.options.transport,
|
|
||||||
debug: this.options.debug,
|
|
||||||
onEnd: function (response) {
|
|
||||||
if (callback) {
|
|
||||||
if (response.status !== grpc.Code.OK) {
|
|
||||||
var err = new Error(response.statusMessage);
|
|
||||||
err.code = response.status;
|
|
||||||
err.metadata = response.trailers;
|
|
||||||
callback(err, null);
|
|
||||||
} else {
|
|
||||||
callback(null, response.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
cancel: function () {
|
|
||||||
callback = null;
|
|
||||||
client.close();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.CofdApiClient = CofdApiClient;
|
|
||||||
|
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
function makeAPI(root) {
|
|
||||||
//Protobuf types
|
|
||||||
const UpdateAttributeRequestType = 'models.proto.cofd.api.UpdateAttributeRequest';
|
|
||||||
const UpdateAttributeRequest = root.lookupType(UpdateAttributeRequestType);
|
|
||||||
|
|
||||||
const UpdateSkillValueRequestType = 'models.proto.cofd.api.UpdateSkillValueRequest';
|
|
||||||
const UpdateSkillValueRequest = root.lookupType(UpdateSkillValueRequestType);
|
|
||||||
|
|
||||||
//TODO rpc-ify
|
|
||||||
const SkillSpecializationUpdateType = 'models.proto.cofd.api.SkillSpecializationsUpdate';
|
|
||||||
const SkillSpecializationsUpdate = root.lookupType(SkillSpecializationUpdateType);
|
|
||||||
|
|
||||||
const protobufContentType = (messageType) =>
|
|
||||||
({ 'Content-Type': 'application/x-protobuf; messageType="' + messageType + '"' });
|
|
||||||
|
|
||||||
function verifyAndCreate(protobufType, payload) {
|
|
||||||
let err = protobufType.verify(payload);
|
|
||||||
if (err) throw err;
|
|
||||||
return protobufType.create(payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function updateAttribute(params) {
|
|
||||||
const { username, characterID, attribute, newValue } = params;
|
|
||||||
|
|
||||||
let req = verifyAndCreate(UpdateAttributeRequest, {
|
|
||||||
characterUsername: username,
|
|
||||||
characterId: parseInt(characterID),
|
|
||||||
attributeName: attribute,
|
|
||||||
attributeValue: parseInt(newValue)
|
|
||||||
});
|
|
||||||
|
|
||||||
let resp = await fetch('/api/rpc/cofd/update_attribute', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { ... protobufContentType(UpdateAttributeRequestType) },
|
|
||||||
body: UpdateAttributeRequest.encode(req).finish()
|
|
||||||
}).then(async resp => {
|
|
||||||
console.log("resp is", await resp.text());
|
|
||||||
}).catch(async err => {
|
|
||||||
console.log("err is", err.text());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function updateSkillValue(params) {
|
|
||||||
const { username, characterID, skillName, newValue } = params;
|
|
||||||
|
|
||||||
let req = verifyAndCreate(UpdateSkillValueRequest, {
|
|
||||||
characterUsername: username,
|
|
||||||
characterId: parseInt(characterID),
|
|
||||||
skillName: skillName,
|
|
||||||
skillValue: parseInt(newValue)
|
|
||||||
});
|
|
||||||
|
|
||||||
let resp = await fetch('/api/rpc/cofd/update_skill_value', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { ... protobufContentType(UpdateSkillValueRequestType) },
|
|
||||||
body: UpdateSkillValueRequest.encode(req).finish()
|
|
||||||
}).then(async resp => {
|
|
||||||
console.log("resp is", await resp.text());
|
|
||||||
}).catch(async err => {
|
|
||||||
console.log("err is", err.text());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
updateAttribute,
|
|
||||||
updateSkillValue
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
(async () => {
|
|
||||||
//TODO start refactoring these into a separate script, and make API calls
|
|
||||||
//take all necessary info (e.g. username and character ID, plus other stuff)
|
|
||||||
//as object params.
|
|
||||||
//const root = await protobuf.load("/protos/cofd_api.proto");
|
|
||||||
|
|
||||||
const [, , USERNAME, CHARACTER_ID] = window.location.pathname.split('/');
|
|
||||||
|
|
||||||
//const api = makeAPI(root);
|
|
||||||
//console.log("api is", api);
|
|
||||||
|
|
||||||
function setupAttributes() {
|
|
||||||
const attributeInputs = document.querySelectorAll('#attributes input[type="number"]');
|
|
||||||
|
|
||||||
async function attributeHandler(event) {
|
|
||||||
console.log("updating attr");
|
|
||||||
const attribute = event.target.id;
|
|
||||||
const newValue = parseInt(event.target.value);
|
|
||||||
const params = { username: USERNAME, characterID: CHARACTER_ID, attribute, newValue };
|
|
||||||
await api.updateAttribute(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
Array.from(attributeInputs).forEach(input => {
|
|
||||||
input.addEventListener('change', attributeHandler);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function setupSkills() {
|
|
||||||
const attributeInputs = document.querySelectorAll('#skills input[type="number"]');
|
|
||||||
|
|
||||||
async function skillValueHandler(event) {
|
|
||||||
console.log("updating skill value");
|
|
||||||
const skillName = event.target.id;
|
|
||||||
const newValue = parseInt(event.target.value);
|
|
||||||
const params = { username: USERNAME, characterID: CHARACTER_ID, skillName, newValue };
|
|
||||||
await api.updateSkillValue(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
Array.from(attributeInputs).forEach(input => {
|
|
||||||
input.addEventListener('change', skillValueHandler);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setupAttributes();
|
|
||||||
setupSkills();
|
|
||||||
})().catch(e => {
|
|
||||||
alert(e);
|
|
||||||
});
|
|
|
@ -1,17 +0,0 @@
|
||||||
document.addEventListener('DOMContentLoaded', event => {
|
|
||||||
protobuf.load("/protos/cofd.proto").then(function(root) {
|
|
||||||
console.log("root is", root);
|
|
||||||
let CofdSheet = root.lookupType("models.proto.cofd.CofdSheet");
|
|
||||||
let sheet = CofdSheet.fromObject({ name: 'lol', strength: 100 });
|
|
||||||
let buffer = CofdSheet.encode(sheet).finish();
|
|
||||||
|
|
||||||
fetch('/proto-test', {
|
|
||||||
method: 'POST',
|
|
||||||
body: buffer
|
|
||||||
}).then(async resp => {
|
|
||||||
console.log("resp is", await resp.text());
|
|
||||||
}).catch(async err => {
|
|
||||||
console.log("err is", err.text());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,8 +0,0 @@
|
||||||
import { grpc } from "@improbable-eng/grpc-web";
|
|
||||||
import { CofdApi } from "../_proto/cofd_api_pb_service";
|
|
||||||
import { UpdateSkillValueRequest } from "../_proto/cofd_api_pb";
|
|
||||||
|
|
||||||
let x = new UpdateSkillValueRequest();
|
|
||||||
x.setCharacterId(1);
|
|
||||||
x.setCharacterUsername("guy");
|
|
||||||
console.log("hello", x);
|
|
|
@ -1,26 +0,0 @@
|
||||||
import * as api from "./api";
|
|
||||||
import { grpc } from "@improbable-eng/grpc-web";
|
|
||||||
import { CofdApi } from "../_proto/cofd_api_pb_service";
|
|
||||||
import { UpdateSkillValueRequest } from "../_proto/cofd_api_pb";
|
|
||||||
import { CofdSheet } from "../_proto/cofd_pb";
|
|
||||||
|
|
||||||
console.log(api.updateSkillValue);
|
|
||||||
let x = new UpdateSkillValueRequest();
|
|
||||||
x.setCharacterId(1);
|
|
||||||
x.setCharacterUsername("guy");
|
|
||||||
console.log("hello", x);
|
|
||||||
|
|
||||||
grpc.invoke(CofdApi.UpdateSkillValue, {
|
|
||||||
request: x,
|
|
||||||
host: window.location.protocol + "//" + window.location.hostname + ":8080",
|
|
||||||
onMessage: (message: CofdSheet.Skill) => {
|
|
||||||
console.log("got skill: ", message.toObject());
|
|
||||||
},
|
|
||||||
onEnd: (code: grpc.Code, msg: string | undefined, trailers: grpc.Metadata) => {
|
|
||||||
if (code == grpc.Code.OK) {
|
|
||||||
console.log("all ok")
|
|
||||||
} else {
|
|
||||||
console.log("hit an error", code, msg, trailers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -20,9 +20,7 @@ function packPage(page, chunks) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: {
|
entry: {
|
||||||
index: "./src/index.ts",
|
|
||||||
edit_character: "./src/characters/edit.ts",
|
edit_character: "./src/characters/edit.ts",
|
||||||
blah: "./src/blah.ts",
|
|
||||||
},
|
},
|
||||||
optimization: {
|
optimization: {
|
||||||
runtimeChunk: "single",
|
runtimeChunk: "single",
|
||||||
|
@ -51,7 +49,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new CleanWebpackPlugin(),
|
new CleanWebpackPlugin(),
|
||||||
packPage('login.html.tera', ['index']),
|
packPage('login.html.tera'),
|
||||||
packPage('base.html.tera'),
|
packPage('base.html.tera'),
|
||||||
packPage('error.html.tera'),
|
packPage('error.html.tera'),
|
||||||
packPage('index.html.tera'),
|
packPage('index.html.tera'),
|
||||||
|
|
Loading…
Reference in New Issue