repo_id stringlengths 6 101 | file_path stringlengths 2 269 | content stringlengths 367 5.14M | size int64 367 5.14M | filename stringlengths 1 248 | ext stringlengths 0 87 | lang stringclasses 88 values | program_lang stringclasses 232 values | doc_type stringclasses 5 values | quality_signal stringlengths 2 1.9k | effective stringclasses 2 values | hit_map stringlengths 2 1.4k |
|---|---|---|---|---|---|---|---|---|---|---|---|
0-1-0/lightblue-0.4 | src/mac/LightAquaBlue/BBBluetoothOBEXClient.h | /*
* Copyright (c) 2009 Bea Lam. All rights reserved.
*
* This file is part of LightBlue.
*
* LightBlue 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 3 of the License, or
* (at your option) any later version.
*
* LightBlue is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
*/
//
// BBBluetoothOBEXClient.h
// LightAquaBlue
//
// Implements the client side of an OBEX session over a Bluetooth transport.
//
// There is an example in examples/LightAquaBlue/SimpleOBEXClient that shows
// how to use this class to connect to and send files to an OBEX server.
//
#import <Cocoa/Cocoa.h>
#import <IOBluetooth/OBEX.h>
#import <IOBluetooth/Bluetooth.h>
@class OBEXSession;
@class BBOBEXHeaderSet;
@class BBOBEXRequest;
@class IOBluetoothDevice;
@class BBOBEXResponse;
@class IOBluetoothRFCOMMChannel;
@interface BBBluetoothOBEXClient : NSObject {
OBEXSession* mSession;
id mDelegate;
OBEXMaxPacketLength mMaxPacketLength;
int mLastServerResponse;
uint32_t mConnectionID;
BOOL mHasConnectionID;
BOOL mAborting;
BBOBEXRequest *mCurrentRequest;
}
/*
* Creates a BBBluetoothOBEXClient with the given <delegate>. The client will
* connect to the OBEX server on the given <deviceAddress> and <channelID>.
*/
- (id)initWithRemoteDeviceAddress:(const BluetoothDeviceAddress *)deviceAddress
channelID:(BluetoothRFCOMMChannelID)channelID
delegate:(id)delegate;
/*
* Sends a Connect request with the given <headers>.
*
* Returns kOBEXSuccess if the request was sent, or some other OBEXError value
* from <IOBluetooth/OBEX.h> if there was an error. The delegate is informed
* through client:didFinishConnectRequestWithError:responseCode:responseHeaders:
* when the request is finished.
*/
- (OBEXError)sendConnectRequestWithHeaders:(BBOBEXHeaderSet *)headers;
/*
* Sends a Disconnect request with the given <headers>.
*
* Returns kOBEXSuccess if the request was sent, or some other OBEXError value
* from <IOBluetooth/OBEX.h> if there was an error. The delegate is informed
* through client:didFinishDisconnectRequestWithError:responseCode:responseHeaders:
* when the request is finished.
*
* You must have already sent a Connect request; otherwise, this fails and
* return kOBEXSessionNotConnectedError.
*
* Note the Connection ID is automatically sent in the request headers if one
* was provided by the server in a previous Connect response.
*/
- (OBEXError)sendDisconnectRequestWithHeaders:(BBOBEXHeaderSet *)headers;
/*
* Sends a Put request with the given <headers> that will send the data from
* the given <inputStream>. (The stream must be already open, or the request
* will fail!) To send a Put-Delete request, set <inputStream> to nil.
*
* Returns kOBEXSuccess if the request was sent, or some other OBEXError value
* from <IOBluetooth/OBEX.h> if there was an error. The delegate is informed
* through client:didFinishPutRequestForStream:error:responseCode:responseHeaders:
* when the request is finished.
*
* You must have already sent a Connect request; otherwise, this fails and
* return kOBEXSessionNotConnectedError.
*
* Note the Connection ID is automatically sent in the request headers if one
* was provided by the server in a previous Connect response.
*/
- (OBEXError)sendPutRequestWithHeaders:(BBOBEXHeaderSet *)headers
readFromStream:(NSInputStream *)inputStream;
/*
* Sends a Get request with the given <headers> that will write received data
* to the given <outputStream>. (The stream must be already open, or the request
* will fail!)
*
* Returns kOBEXSuccess if the request was sent, or some other OBEXError value
* from <IOBluetooth/OBEX.h> if there was an error. The delegate is informed
* through client:didFinishGetRequestForStream:error:responseCode:responseHeaders:
* when the request is finished.
*
* You must have already sent a Connect request; otherwise, this fails and
* return kOBEXSessionNotConnectedError.
*
* Note the Connection ID is automatically sent in the request headers if one
* was provided by the server in a previous Connect response.
*/
- (OBEXError)sendGetRequestWithHeaders:(BBOBEXHeaderSet *)headers
writeToStream:(NSOutputStream *)outputStream;
/*
* Sends a SetPath request with the given <headers>. Set
* <changeToParentDirectoryFirst> to YES if you want to move up one directory
* (i.e. "..") before changing to the directory specified in the headers. Set
* <createDirectoriesIfNeeded> to YES if you want to create a directory
* (instead of receiving an error response) if it does not currently exist.
*
* Returns kOBEXSuccess if the request was sent, or some other OBEXError value
* from <IOBluetooth/OBEX.h> if there was an error. The delegate is informed
* through client:didFinishSetPathRequestWithError:responseCode:responseHeaders:
* when the request is finished.
*
* You must have already sent a Connect request; otherwise, this fails and
* return kOBEXSessionNotConnectedError.
*
* Note the Connection ID is automatically sent in the request headers if one
* was provided by the server in a previous Connect response.
*/
- (OBEXError)sendSetPathRequestWithHeaders:(BBOBEXHeaderSet *)headers
changeToParentDirectoryFirst:(BOOL)changeToParentDirectoryFirst
createDirectoriesIfNeeded:(BOOL)createDirectoriesIfNeeded;
/*
* Aborts the current request if a Put or Get request is currently in progress.
*
* This schedules an Abort request to be sent when possible (i.e. when the
* client next receives a server response).
*
* Returns kOBEXSuccess if the request was sent, or some other OBEXError value
* from <IOBluetooth/OBEX.h> if there was an error. The delegate is informed
* through client:didFinishAbortRequestWithError:responseCode:forStream:
* when the Abort request is finished.
*/
- (void)abortCurrentRequest;
/*
* Returns whether the OBEX session is connected (i.e. whether a Connect
* request has been sent, without a following Disconnect request).
*/
- (BOOL)isConnected;
/*
* Returns the Connection ID for the OBEX session, if one was received in a
* response to a previous Connect request.
*
* This is automatically sent by the client for each request; you do not need
* to add it to the request headers yourself.
*/
- (uint32_t)connectionID;
/*
* Returns the RFCOMM channel for the client.
*/
- (IOBluetoothRFCOMMChannel *)RFCOMMChannel;
/*
* Returns whether this client has a Connection ID.
*/
- (BOOL)hasConnectionID;
/*
* Returns the maximum packet length for the OBEX session.
*/
- (OBEXMaxPacketLength)maximumPacketLength;
/*
* Sets the client delegate to <delegate>.
*/
- (void)setDelegate:(id)delegate;
/*
* Returns the delegate for this client.
*/
- (id)delegate;
/*
* Sets whether debug messages should be displayed (default is NO).
*/
+ (void)setDebug:(BOOL)debug;
@end
/*
* This informal protocol describes the methods that can be implemented for a
* BBBluetoothOBEXClient delegate.
*/
@protocol BBBluetoothOBEXClientDelegate
/*
* Called when a Connect request is completed. <error> is set to kOBEXSuccess
* if the request finished without an error, or some other OBEXError value
* from <IOBluetooth/OBEX.h> if an error occured. <response> contains the
* response code and headers.
*
* The <error> only indicates whether the request was processed successfully;
* use the response code in <response> to see whether the request was actually
* accepted by the OBEX server.
*/
- (void)client:(BBBluetoothOBEXClient *)client
didFinishConnectRequestWithError:(OBEXError)error
response:(BBOBEXResponse *)response;
/*
* Called when a Disconnect request is completed. <error> is set to kOBEXSuccess
* if the request finished without an error, or some other OBEXError value
* from <IOBluetooth/OBEX.h> if an error occured. <response> contains the
* response code and headers.
*
* The <error> only indicates whether the request was processed successfully;
* use the response code in <response> to see whether the request was actually
* accepted by the OBEX server.
*/
- (void)client:(BBBluetoothOBEXClient *)client
didFinishDisconnectRequestWithError:(OBEXError)error
response:(BBOBEXResponse *)response;
/*
* Called when a Put request is completed. <error> is set to kOBEXSuccess
* if the request finished without an error, or some other OBEXError value
* from <IOBluetooth/OBEX.h> if an error occured. The <inputStream> is the
* stream originally passed to sendPutRequestWithHeaders:readFromStream:, and
* <response> contains the response code and headers.
*
* The <error> only indicates whether the request was processed successfully;
* use the response code in <response> to see whether the request was actually
* accepted by the OBEX server.
*/
- (void)client:(BBBluetoothOBEXClient *)client
didFinishPutRequestForStream:(NSInputStream *)inputStream
error:(OBEXError)error
response:(BBOBEXResponse *)response;
/*
* Called each time the client sends another chunk of data to the OBEX server
* during a Put request. <length> is the number of bytes sent.
*/
- (void)client:(BBBluetoothOBEXClient *)client
didSendDataOfLength:(unsigned)length;
/*
* Called each time the client receives another chunk of data from the OBEX
* server during a Get request. <length> is the number of bytes received, and
* <totalLength> is the total number of bytes the client expects to receive
* for the request. <totalLength> is zero if the total length is unknown.
*/
- (void)client:(BBBluetoothOBEXClient *)session
didReceiveDataOfLength:(unsigned)length
ofTotalLength:(unsigned)totalLength;
/*
* Called when a Get request is completed. <error> is set to kOBEXSuccess
* if the request finished without an error, or some other OBEXError value
* from <IOBluetooth/OBEX.h> if an error occured. The <outputStream> is the
* stream originally passed to sendGetRequestWithHeaders:writeToStream:, and
* <response> contains the response code and headers.
*
* The <error> only indicates whether the request was processed successfully;
* use the response code in <response> to see whether the request was actually
* accepted by the OBEX server.
*/
- (void)client:(BBBluetoothOBEXClient *)client
didFinishGetRequestForStream:(NSOutputStream *)outputStream
error:(OBEXError)error
response:(BBOBEXResponse *)response;
/*
* Called when a SetPath request is completed. <error> is set to kOBEXSuccess
* if the request finished without an error, or some other OBEXError value
* from <IOBluetooth/OBEX.h> if an error occured. <response> contains the
* response code and headers.
*
* The <error> only indicates whether the request was processed successfully;
* use the response code in <response> to see whether the request was actually
* accepted by the OBEX server.
*/
- (void)client:(BBBluetoothOBEXClient *)client
didFinishSetPathRequestWithError:(OBEXError)error
response:(BBOBEXResponse *)response;
/*
* Called when an Abort request is completed following a call to
* abortCurrentRequest:. <error> is set to kOBEXSuccess
* if the request finished without an error, or some other OBEXError value
* from <IOBluetooth/OBEX.h> if an error occured. The <stream> is the
* stream originally passed to sendPutRequestWithHeaders:readFromStream: or
* sendGetRequestWithHeaders:writeToStream:, and <response> contains the
* response code and headers.
*
* The <error> only indicates whether the request was processed successfully;
* use the response code in <response> to see whether the request was actually
* accepted by the OBEX server.
*/
- (void)client:(BBBluetoothOBEXClient *)session
didAbortRequestWithStream:(NSStream *)stream
error:(OBEXError)error
response:(BBOBEXResponse *)response;
@end
| 12,375 | BBBluetoothOBEXClient | h | en | c | code | {"qsc_code_num_words": 1548, "qsc_code_num_chars": 12375.0, "qsc_code_mean_word_length": 6.00839793, "qsc_code_frac_words_unique": 0.18863049, "qsc_code_frac_chars_top_2grams": 0.03978067, "qsc_code_frac_chars_top_3grams": 0.02515859, "qsc_code_frac_chars_top_4grams": 0.03096441, "qsc_code_frac_chars_dupe_5grams": 0.55262875, "qsc_code_frac_chars_dupe_6grams": 0.53843673, "qsc_code_frac_chars_dupe_7grams": 0.52058918, "qsc_code_frac_chars_dupe_8grams": 0.48887216, "qsc_code_frac_chars_dupe_9grams": 0.45651005, "qsc_code_frac_chars_dupe_10grams": 0.45651005, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00088183, "qsc_code_frac_chars_whitespace": 0.17527273, "qsc_code_size_file_byte": 12375.0, "qsc_code_num_lines": 327.0, "qsc_code_num_chars_line_max": 85.0, "qsc_code_num_chars_line_mean": 37.8440367, "qsc_code_frac_chars_alphabet": 0.91044484, "qsc_code_frac_chars_comments": 0.76420202, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.27536232, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codec_frac_lines_func_ratio": 0.0, "qsc_codec_cate_bitsstdc": 0.0, "qsc_codec_nums_lines_main": 0, "qsc_codec_frac_lines_goto": 0.0, "qsc_codec_cate_var_zero": 0.0, "qsc_codec_score_lines_no_logic": 0.01449275, "qsc_codec_frac_lines_print": 0.0, "qsc_codec_frac_lines_preprocessor_directives": null} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codec_frac_lines_func_ratio": 0, "qsc_codec_nums_lines_main": 0, "qsc_codec_score_lines_no_logic": 0, "qsc_codec_frac_lines_preprocessor_directives": 0, "qsc_codec_frac_lines_print": 0} |
0-1-0/lightblue-0.4 | src/mac/LightAquaBlue/BBServiceAdvertiser.m | /*
* Copyright (c) 2009 Bea Lam. All rights reserved.
*
* This file is part of LightBlue.
*
* LightBlue 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 3 of the License, or
* (at your option) any later version.
*
* LightBlue is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
*/
//
// BBServiceAdvertiser.m
// LightAquaBlue
//
#import <IOBluetooth/IOBluetoothUserLib.h>
#import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h>
#import <IOBluetooth/objc/IOBluetoothSDPUUID.h>
#import "BBServiceAdvertiser.h"
static NSString *kServiceItemKeyServiceClassIDList;
static NSString *kServiceItemKeyServiceName;
static NSString *kServiceItemKeyProtocolDescriptorList;
// template service dictionaries for each pre-defined profile
static NSDictionary *serialPortProfileDict;
static NSDictionary *objectPushProfileDict;
static NSDictionary *fileTransferProfileDict;
@implementation BBServiceAdvertiser
+ (void)initialize
{
kServiceItemKeyServiceClassIDList = @"0001 - ServiceClassIDList";
kServiceItemKeyServiceName = @"0100 - ServiceName*";
kServiceItemKeyProtocolDescriptorList = @"0004 - ProtocolDescriptorList";
// initialize the template service dictionaries
NSBundle *classBundle = [NSBundle bundleForClass:[BBServiceAdvertiser class]];
serialPortProfileDict =
[[NSDictionary alloc] initWithContentsOfFile:[classBundle pathForResource:@"SerialPortDictionary"
ofType:@"plist"]];
objectPushProfileDict =
[[NSDictionary alloc] initWithContentsOfFile:[classBundle pathForResource:@"OBEXObjectPushDictionary"
ofType:@"plist"]];
fileTransferProfileDict =
[[NSDictionary alloc] initWithContentsOfFile:[classBundle pathForResource:@"OBEXFileTransferDictionary"
ofType:@"plist"]];
//kRFCOMMChannelNone = 0;
//kRFCOMM_UUID = [[IOBluetoothSDPUUID uuid16:kBluetoothSDPUUID16RFCOMM] retain];
}
+ (NSDictionary *)serialPortProfileDictionary
{
return serialPortProfileDict;
}
+ (NSDictionary *)objectPushProfileDictionary
{
return objectPushProfileDict;
}
+ (NSDictionary *)fileTransferProfileDictionary
{
return fileTransferProfileDict;
}
+ (void)updateServiceDictionary:(NSMutableDictionary *)sdpEntries
withName:(NSString *)serviceName
withUUID:(IOBluetoothSDPUUID *)uuid
{
if (sdpEntries == nil) return;
// set service name
if (serviceName != nil) {
[sdpEntries setObject:serviceName forKey:kServiceItemKeyServiceName];
}
// set service uuid if given
if (uuid != nil) {
NSMutableArray *currentServiceList =
[sdpEntries objectForKey:kServiceItemKeyServiceClassIDList];
if (currentServiceList == nil) {
currentServiceList = [NSMutableArray array];
}
[currentServiceList addObject:[NSData dataWithBytes:[uuid bytes] length:[uuid length]]];
// update dict
[sdpEntries setObject:currentServiceList forKey:kServiceItemKeyServiceClassIDList];
}
}
+ (IOReturn)addRFCOMMServiceDictionary:(NSDictionary *)dict
withName:(NSString *)serviceName
UUID:(IOBluetoothSDPUUID *)uuid
channelID:(BluetoothRFCOMMChannelID *)outChannelID
serviceRecordHandle:(BluetoothSDPServiceRecordHandle *)outServiceRecordHandle
{
if (dict == nil)
return kIOReturnError;
NSMutableDictionary *sdpEntries = [NSMutableDictionary dictionaryWithDictionary:dict];
[BBServiceAdvertiser updateServiceDictionary:sdpEntries
withName:serviceName
withUUID:uuid];
// publish the service
IOBluetoothSDPServiceRecordRef serviceRecordRef;
IOReturn status = IOBluetoothAddServiceDict((CFDictionaryRef) sdpEntries, &serviceRecordRef);
if (status == kIOReturnSuccess) {
IOBluetoothSDPServiceRecord *serviceRecord =
[IOBluetoothSDPServiceRecord withSDPServiceRecordRef:serviceRecordRef];
// get service channel ID & service record handle
status = [serviceRecord getRFCOMMChannelID:outChannelID];
if (status == kIOReturnSuccess) {
status = [serviceRecord getServiceRecordHandle:outServiceRecordHandle];
}
// cleanup
IOBluetoothObjectRelease(serviceRecordRef);
}
return status;
}
+ (IOReturn)removeService:(BluetoothSDPServiceRecordHandle)handle
{
return IOBluetoothRemoveServiceWithRecordHandle(handle);
}
@end
| 4,836 | BBServiceAdvertiser | m | en | limbo | code | {"qsc_code_num_words": 375, "qsc_code_num_chars": 4836.0, "qsc_code_mean_word_length": 9.552, "qsc_code_frac_words_unique": 0.496, "qsc_code_frac_chars_top_2grams": 0.0041876, "qsc_code_frac_chars_top_3grams": 0.01088777, "qsc_code_frac_chars_top_4grams": 0.0159129, "qsc_code_frac_chars_dupe_5grams": 0.0773311, "qsc_code_frac_chars_dupe_6grams": 0.01563372, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0055332, "qsc_code_frac_chars_whitespace": 0.17783292, "qsc_code_size_file_byte": 4836.0, "qsc_code_num_lines": 154.0, "qsc_code_num_chars_line_max": 106.0, "qsc_code_num_chars_line_mean": 31.4025974, "qsc_code_frac_chars_alphabet": 0.89537223, "qsc_code_frac_chars_comments": 0.03722084, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.07826087, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.03393471, "qsc_code_frac_chars_long_word_length": 0.01546392, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
0-1-0/lightblue-0.4 | src/mac/LightAquaBlue/BBServiceAdvertiser.h | /*
* Copyright (c) 2009 Bea Lam. All rights reserved.
*
* This file is part of LightBlue.
*
* LightBlue 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 3 of the License, or
* (at your option) any later version.
*
* LightBlue is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
*/
//
// BBServiceAdvertiser.h
// LightAquaBlue
//
// Provides some basic operations for advertising Bluetooth services.
//
#import <IOBluetooth/Bluetooth.h>
@class IOBluetoothSDPUUID;
@interface BBServiceAdvertiser : NSObject {
//
}
/*
* Returns a ready-made dictionary for advertising a service with the Serial
* Port Profile.
*/
+ (NSDictionary *)serialPortProfileDictionary;
/*
* Returns a ready-made dictionary for advertising a service with the OBEX
* Object Push Profile.
*/
+ (NSDictionary *)objectPushProfileDictionary;
/*
* Returns a ready-made dictionary for advertising a service with the OBEX
* File Transfer Profile.
*/
+ (NSDictionary *)fileTransferProfileDictionary;
/*
* Advertise a RFCOMM-based (i.e. RFCOMM or OBEX) service.
*
* Arguments:
* - dict: the dictionary containing the service details.
* - serviceName: the service name to advertise, which will be added to the
* dictionary. Can be nil.
* - uuid: the custom UUID to advertise for the service, which will be added to
* the dictionary. Can be nil.
* - outChannelID: once the service is advertised, this will be set to the
* RFCOMM channel ID that was used to advertise the service.
* - outServiceRecordHandle: once the service is advertised, this will be set
* to the service record handle which identifies the service.
*/
+ (IOReturn)addRFCOMMServiceDictionary:(NSDictionary *)dict
withName:(NSString *)serviceName
UUID:(IOBluetoothSDPUUID *)uuid
channelID:(BluetoothRFCOMMChannelID *)outChannelID
serviceRecordHandle:(BluetoothSDPServiceRecordHandle *)outServiceRecordHandle;
/*
* Stop advertising a service.
*/
+ (IOReturn)removeService:(BluetoothSDPServiceRecordHandle)handle;
@end
| 2,483 | BBServiceAdvertiser | h | en | c | code | {"qsc_code_num_words": 304, "qsc_code_num_chars": 2483.0, "qsc_code_mean_word_length": 6.03289474, "qsc_code_frac_words_unique": 0.48026316, "qsc_code_frac_chars_top_2grams": 0.0436205, "qsc_code_frac_chars_top_3grams": 0.04143948, "qsc_code_frac_chars_top_4grams": 0.03107961, "qsc_code_frac_chars_dupe_5grams": 0.23118866, "qsc_code_frac_chars_dupe_6grams": 0.217012, "qsc_code_frac_chars_dupe_7grams": 0.18647764, "qsc_code_frac_chars_dupe_8grams": 0.18647764, "qsc_code_frac_chars_dupe_9grams": 0.18647764, "qsc_code_frac_chars_dupe_10grams": 0.18647764, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00246305, "qsc_code_frac_chars_whitespace": 0.1824406, "qsc_code_size_file_byte": 2483.0, "qsc_code_num_lines": 78.0, "qsc_code_num_chars_line_max": 86.0, "qsc_code_num_chars_line_mean": 31.83333333, "qsc_code_frac_chars_alphabet": 0.90098522, "qsc_code_frac_chars_comments": 0.74667741, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codec_frac_lines_func_ratio": 0.0, "qsc_codec_cate_bitsstdc": 0.0, "qsc_codec_nums_lines_main": 0, "qsc_codec_frac_lines_goto": 0.0, "qsc_codec_cate_var_zero": 0.0, "qsc_codec_score_lines_no_logic": 0.0, "qsc_codec_frac_lines_print": 0.0, "qsc_codec_frac_lines_preprocessor_directives": null} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codec_frac_lines_func_ratio": 0, "qsc_codec_nums_lines_main": 0, "qsc_codec_score_lines_no_logic": 0, "qsc_codec_frac_lines_preprocessor_directives": 0, "qsc_codec_frac_lines_print": 0} |
0-1-0/lightblue-0.4 | src/mac/LightAquaBlue/BBMutableOBEXHeaderSet.m | /*
* Copyright (c) 2009 Bea Lam. All rights reserved.
*
* This file is part of LightBlue.
*
* LightBlue 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 3 of the License, or
* (at your option) any later version.
*
* LightBlue is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
*/
//
// BBMutableOBEXHeaderSet.m
// LightAquaBlue
//
#import "BBMutableOBEXHeaderSet.h"
enum kOBEXHeaderEncoding {
kHeaderEncodingMask = 0xc0,
kHeaderEncodingUnicode = 0x00,
kHeaderEncodingByteSequence = 0x40,
kHeaderEncoding1Byte = 0x80,
kHeaderEncoding4Byte = 0xc0
};
static NSString *LOCAL_TIME_FORMAT_STRING = @"%Y%m%dT%H%M%S";
static NSString *UTC_FORMAT_STRING = @"%Y%m%dT%H%M%SZ";
@implementation BBMutableOBEXHeaderSet
+ (id)headerSet
{
return [[[BBMutableOBEXHeaderSet alloc] init] autorelease];
}
- (void)setValueForCountHeader:(uint32_t)count
{
[self setValue:count for4ByteHeader:kOBEXHeaderIDCount];
}
- (void)setValueForNameHeader:(NSString *)name
{
[self setValue:name forUnicodeHeader:kOBEXHeaderIDName];
}
- (void)setValueForTypeHeader:(NSString *)type
{
NSMutableData *data;
if ([type length] == 0) {
data = [NSMutableData data];
} else {
const char *s = [type cStringUsingEncoding:NSASCIIStringEncoding];
if (!s) // cannot be converted to ascii
return;
// add null terminator
data = [NSMutableData dataWithBytes:s
length:[type length] + 1];
[data resetBytesInRange:NSMakeRange([type length], 1)];
}
[self setValue:data forByteSequenceHeader:kOBEXHeaderIDType];
}
- (void)setValueForLengthHeader:(uint32_t)length
{
[self setValue:length for4ByteHeader:kOBEXHeaderIDLength];
}
- (void)setValueForTimeHeader:(NSDate *)date
{
[self setValueForTimeHeader:date isUTCTime:NO];
}
- (void)setValueForTimeHeader:(NSDate *)date isUTCTime:(BOOL)isUTCTime
{
NSString *dateString =
[date descriptionWithCalendarFormat: (isUTCTime ? UTC_FORMAT_STRING : LOCAL_TIME_FORMAT_STRING)
timeZone: (isUTCTime ? [NSTimeZone timeZoneWithName:@"UTC"] : [NSTimeZone localTimeZone])
locale: nil];
[self setValue:[dateString dataUsingEncoding:NSASCIIStringEncoding]
forByteSequenceHeader:kOBEXHeaderIDTimeISO];
}
- (void)setValueForDescriptionHeader:(NSString *)description
{
[self setValue:description forUnicodeHeader:kOBEXHeaderIDDescription];
}
- (void)setValueForTargetHeader:(NSData *)target
{
[self setValue:target forByteSequenceHeader:kOBEXHeaderIDTarget];
}
- (void)setValueForHTTPHeader:(NSData *)http
{
[self setValue:http forByteSequenceHeader:kOBEXHeaderIDHTTP];
}
- (void)setValueForWhoHeader:(NSData *)who
{
[self setValue:who forByteSequenceHeader:kOBEXHeaderIDWho];
}
- (void)setValueForConnectionIDHeader:(uint32_t)connectionID
{
[self setValue:connectionID for4ByteHeader:kOBEXHeaderIDConnectionID];
}
- (void)setValueForApplicationParametersHeader:(NSData *)appParameters
{
[self setValue:appParameters forByteSequenceHeader:kOBEXHeaderIDAppParameters];
}
- (void)setValueForAuthorizationChallengeHeader:(NSData *)authChallenge
{
[self setValue:authChallenge forByteSequenceHeader:kOBEXHeaderIDAuthorizationChallenge];
}
- (void)setValueForAuthorizationResponseHeader:(NSData *)authResponse
{
[self setValue:authResponse forByteSequenceHeader:kOBEXHeaderIDAuthorizationResponse];
}
- (void)setValueForObjectClassHeader:(NSData *)objectClass
{
[self setValue:objectClass forByteSequenceHeader:0x51];
}
- (void)setValue:(NSString *)value forUnicodeHeader:(uint8_t)headerID
{
if (!value || ((headerID & kHeaderEncodingMask) != kHeaderEncodingUnicode))
return;
NSNumber *key = [NSNumber numberWithUnsignedChar:headerID];
if ([mDict objectForKey:key] == nil)
[mKeys addObject:key];
[mDict setObject:value forKey:key];
}
- (void)setValue:(NSData *)value forByteSequenceHeader:(uint8_t)headerID
{
if (!value || ((headerID & kHeaderEncodingMask) != kHeaderEncodingByteSequence))
return;
NSNumber *key = [NSNumber numberWithUnsignedChar:headerID];
if ([mDict objectForKey:key] == nil)
[mKeys addObject:key];
[mDict setObject:value forKey:key];
}
- (void)setValue:(uint32_t)value for4ByteHeader:(uint8_t)headerID
{
if ((headerID & kHeaderEncodingMask) != kHeaderEncoding4Byte)
return;
NSNumber *key = [NSNumber numberWithUnsignedChar:headerID];
if ([mDict objectForKey:key] == nil)
[mKeys addObject:key];
[mDict setObject:[NSNumber numberWithUnsignedInt:value] forKey:key];
}
- (void)setValue:(uint8_t)value for1ByteHeader:(uint8_t)headerID
{
if ((headerID & kHeaderEncodingMask) != kHeaderEncoding1Byte)
return;
NSNumber *key = [NSNumber numberWithUnsignedChar:headerID];
if ([mDict objectForKey:key] == nil)
[mKeys addObject:key];
[mDict setObject:[NSNumber numberWithUnsignedChar:value] forKey:key];
}
- (void)addHeadersFromHeaderSet:(BBOBEXHeaderSet *)headerSet
{
NSDictionary *dict = [headerSet valueForKey:@"mDict"];
[mDict addEntriesFromDictionary:dict];
NSArray *keys = [headerSet allHeaders];
int i;
for (i=0; i<[keys count]; i++) {
if (![mKeys containsObject:[keys objectAtIndex:i]]) {
[mKeys addObject:[keys objectAtIndex:i]];
}
}
}
static uint16_t parseUInt16(const uint8_t *bytes)
{
uint16_t value;
memcpy((void *)&value, bytes, sizeof(value));
return NSSwapBigShortToHost(value);
}
static uint32_t parseUInt32(const uint8_t *bytes)
{
uint32_t value;
memcpy((void *)&value, bytes, sizeof(value));
return NSSwapBigIntToHost(value);
}
static NSString *parseString(const uint8_t *bytes, unsigned int length)
{
if (length < 0)
return nil;
NSString *s = [[NSString alloc] initWithBytes:bytes
length:length
encoding:NSUnicodeStringEncoding];
return [s autorelease];
}
static NSData *parseData(const uint8_t *bytes, unsigned int length)
{
if (length < 0)
return nil;
return [NSData dataWithBytes:bytes length:length];
}
- (BOOL)addHeadersFromHeadersData:(const uint8_t *)headersData
length:(size_t)length
{
if (length == 0) // nothing to add
return YES;
if (length == 1) // must have at least 2 headersData
return NO;
NSNumber *hi;
uint16_t hlen;
//NSLog(@"reading %d bytes", length);
int i = 0;
while (i < length) {
hi = [NSNumber numberWithUnsignedChar:headersData[i]];
//NSLog(@"Next header: %d", headersData[i]);
switch (headersData[i] & kHeaderEncodingMask) {
case kHeaderEncoding4Byte: // ID V V V V
{
//NSLog(@"\tint:");
hlen = 5;
if (i + hlen > length)
return NO;
[self setValue:parseUInt32(&headersData[i+1]) for4ByteHeader:headersData[i]];
break;
}
case kHeaderEncoding1Byte: // ID V
{
//NSLog(@"\tbyte:");
hlen = 2;
if (i + hlen > length)
return NO;
[self setValue:headersData[i+1] for1ByteHeader:headersData[i]];
break;
}
case kHeaderEncodingUnicode: // ID L L V V .. .. O O
{
//NSLog(@"\tunicode:");
if (i + 3 > length)
return NO;
hlen = parseUInt16(&headersData[i+1]);
if (i + hlen > length)
return NO;
NSString *s = nil;
if (hlen - 3 == 0) { // empty string (3 headersData is for ID + length)
s = [NSString string];
} else {
// account for 3 headersData of ID + length
s = parseString(&headersData[i+3], (hlen - 3 - 2));
}
if (!s)
return NO;
[self setValue:s forUnicodeHeader:headersData[i]];
break;
}
case kHeaderEncodingByteSequence: // ID L L V ..
{
//NSLog(@"\tbyte stream:");
if (i + 3 > length)
return NO;
hlen = parseUInt16(&headersData[i+1]);
//NSLog(@"\tbytes length: %d", hlen);
if (i + hlen > length)
return NO;
NSData *data = nil;
if (hlen - 3 == 0) {
data = [NSData data];
} else {
// account for 3 headersData of ID + length
data = parseData(&headersData[i+3], hlen-3);
}
//NSLog(@"\tread bytes");
if (!data)
return NO;
[self setValue:data forByteSequenceHeader:headersData[i]];
break;
}
}
i += hlen;
//NSLog(@"\tRead header ok, now to index %d...", i);
}
//NSLog(@"\tFinished reading headers");
return YES;
}
- (void)removeValueForHeader:(uint8_t)headerID
{
NSNumber *number = [NSNumber numberWithUnsignedChar:headerID];
[mDict removeObjectForKey:number];
[mKeys removeObject:number];
}
@end
| 10,001 | BBMutableOBEXHeaderSet | m | en | limbo | code | {"qsc_code_num_words": 914, "qsc_code_num_chars": 10001.0, "qsc_code_mean_word_length": 6.702407, "qsc_code_frac_words_unique": 0.29868709, "qsc_code_frac_chars_top_2grams": 0.03525955, "qsc_code_frac_chars_top_3grams": 0.01371205, "qsc_code_frac_chars_top_4grams": 0.01044727, "qsc_code_frac_chars_dupe_5grams": 0.22135162, "qsc_code_frac_chars_dupe_6grams": 0.20339536, "qsc_code_frac_chars_dupe_7grams": 0.17335945, "qsc_code_frac_chars_dupe_8grams": 0.15181195, "qsc_code_frac_chars_dupe_9grams": 0.12928501, "qsc_code_frac_chars_dupe_10grams": 0.11524649, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01421082, "qsc_code_frac_chars_whitespace": 0.27527247, "qsc_code_size_file_byte": 10001.0, "qsc_code_num_lines": 321.0, "qsc_code_num_chars_line_max": 125.0, "qsc_code_num_chars_line_mean": 31.15576324, "qsc_code_frac_chars_alphabet": 0.83098786, "qsc_code_frac_chars_comments": 0.00349965, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.19855596, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01956653, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00240819, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
0-1-0/lightblue-0.4 | src/mac/LightAquaBlue/BBStreamingInputStream.h | /*
* Copyright (c) 2009 Bea Lam. All rights reserved.
*
* This file is part of LightBlue.
*
* LightBlue 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 3 of the License, or
* (at your option) any later version.
*
* LightBlue is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
*/
//
// BBDelegatingInputStream.h
// LightAquaBlue
//
// A NSInputStream subclass that calls readDataWithMaxLength: on the delegate
// when data is required.
// This class is only intended for use from the LightBlue library.
// Most methods are not implemented, and there are no stream:HandleEvent:
// calls to the delegate.
//
#import <Cocoa/Cocoa.h>
@interface BBStreamingInputStream : NSInputStream {
id mDelegate;
NSStreamStatus mStatus;
}
- (id)initWithDelegate:(id)delegate;
@end
@protocol BBStreamingInputStreamDelegate
- (NSData *)readDataWithMaxLength:(unsigned int)maxLength;
@end
| 1,351 | BBStreamingInputStream | h | en | c | code | {"qsc_code_num_words": 181, "qsc_code_num_chars": 1351.0, "qsc_code_mean_word_length": 5.5359116, "qsc_code_frac_words_unique": 0.6519337, "qsc_code_frac_chars_top_2grams": 0.01497006, "qsc_code_frac_chars_top_3grams": 0.03892216, "qsc_code_frac_chars_top_4grams": 0.05688623, "qsc_code_frac_chars_dupe_5grams": 0.08183633, "qsc_code_frac_chars_dupe_6grams": 0.05588822, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00451671, "qsc_code_frac_chars_whitespace": 0.18060696, "qsc_code_size_file_byte": 1351.0, "qsc_code_num_lines": 48.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 28.14583333, "qsc_code_frac_chars_alphabet": 0.90063234, "qsc_code_frac_chars_comments": 0.79126573, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.2, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codec_frac_lines_func_ratio": 0.0, "qsc_codec_cate_bitsstdc": 0.0, "qsc_codec_nums_lines_main": 0, "qsc_codec_frac_lines_goto": 0.0, "qsc_codec_cate_var_zero": 0.0, "qsc_codec_score_lines_no_logic": 0.0, "qsc_codec_frac_lines_print": 0.0, "qsc_codec_frac_lines_preprocessor_directives": null} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codec_frac_lines_func_ratio": 0, "qsc_codec_nums_lines_main": 0, "qsc_codec_score_lines_no_logic": 0, "qsc_codec_frac_lines_preprocessor_directives": 0, "qsc_codec_frac_lines_print": 0} |
0-1-0/lightblue-0.4 | src/mac/LightAquaBlue/BBBluetoothOBEXClient.m | /*
* Copyright (c) 2009 Bea Lam. All rights reserved.
*
* This file is part of LightBlue.
*
* LightBlue 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 3 of the License, or
* (at your option) any later version.
*
* LightBlue is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
*/
//
// BBBluetoothOBEXClient.m
// LightAquaBlue
//
#import "BBBluetoothOBEXClient.h"
#import "BBMutableOBEXHeaderSet.h"
#import "BBOBEXRequest.h"
#import <IOBluetooth/objc/OBEXSession.h>
#import <IOBluetooth/objc/IOBluetoothDevice.h>
#import <IOBluetooth/objc/IOBluetoothOBEXSession.h>
#import <CoreFoundation/CoreFoundation.h>
#define DEBUG_NAME @"[BBBluetoothOBEXClient] "
static BOOL _debug = NO;
@implementation BBBluetoothOBEXClient
- (id)initWithRemoteDeviceAddress:(const BluetoothDeviceAddress *)deviceAddress
channelID:(BluetoothRFCOMMChannelID)channelID
delegate:(id)delegate;
{
self = [super init];
mSession = [[IOBluetoothOBEXSession alloc] initWithDevice:[IOBluetoothDevice withAddress:deviceAddress]
channelID:channelID];
mDelegate = delegate;
mMaxPacketLength = 0x2000;
mLastServerResponse = kOBEXResponseCodeSuccessWithFinalBit;
mConnectionID = 0;
mHasConnectionID = NO;
mAborting = NO;
mCurrentRequest = nil;
return self;
}
- (BBOBEXHeaderSet *)addConnectionIDToHeaders:(BBOBEXHeaderSet *)headers
{
if (!mHasConnectionID)
return headers;
BBMutableOBEXHeaderSet *modifiedHeaders = [BBMutableOBEXHeaderSet headerSet];
[modifiedHeaders addHeadersFromHeaderSet:headers];
[modifiedHeaders setValueForConnectionIDHeader:mConnectionID];
return modifiedHeaders;
}
- (OBEXError)sendConnectRequestWithHeaders:(BBOBEXHeaderSet *)headers
{
if (mCurrentRequest && ![mCurrentRequest isFinished])
return kOBEXSessionBusyError;
BBOBEXConnectRequest *request =
[[BBOBEXConnectRequest alloc] initWithClient:self
eventSelector:@selector(handleSessionEvent:)
session:mSession];
OBEXError status = [request beginWithHeaders:headers];
if (status == kOBEXSuccess) {
[mCurrentRequest release];
mCurrentRequest = request;
} else {
[request release];
}
return status;
}
- (OBEXError)sendDisconnectRequestWithHeaders:(BBOBEXHeaderSet *)headers
{
if (mCurrentRequest && ![mCurrentRequest isFinished])
return kOBEXSessionBusyError;
BBOBEXDisconnectRequest *request =
[[BBOBEXDisconnectRequest alloc] initWithClient:self
eventSelector:@selector(handleSessionEvent:)
session:mSession];
BBOBEXHeaderSet *realHeaders = (mHasConnectionID ?
[self addConnectionIDToHeaders:headers] : headers);
OBEXError status = [request beginWithHeaders:realHeaders];
if (status == kOBEXSuccess) {
[mCurrentRequest release];
mCurrentRequest = request;
} else {
[request release];
}
return status;
}
- (OBEXError)sendPutRequestWithHeaders:(BBOBEXHeaderSet *)headers
readFromStream:(NSInputStream *)inputStream
{
if (mCurrentRequest && ![mCurrentRequest isFinished])
return kOBEXSessionBusyError;
BBOBEXPutRequest *request =
[[BBOBEXPutRequest alloc] initWithClient:self
eventSelector:@selector(handleSessionEvent:)
session:mSession
inputStream:inputStream];
BBOBEXHeaderSet *realHeaders = (mHasConnectionID ?
[self addConnectionIDToHeaders:headers] : headers);
OBEXError status = [request beginWithHeaders:realHeaders];
if (status == kOBEXSuccess) {
[mCurrentRequest release];
mCurrentRequest = request;
} else {
[request release];
}
return status;
}
- (OBEXError)sendGetRequestWithHeaders:(BBOBEXHeaderSet *)headers
writeToStream:(NSOutputStream *)outputStream
{
if (mCurrentRequest && ![mCurrentRequest isFinished])
return kOBEXSessionBusyError;
BBOBEXGetRequest *request =
[[BBOBEXGetRequest alloc] initWithClient:self
eventSelector:@selector(handleSessionEvent:)
session:mSession
outputStream:outputStream];
BBOBEXHeaderSet *realHeaders = (mHasConnectionID ?
[self addConnectionIDToHeaders:headers] : headers);
OBEXError status = [request beginWithHeaders:realHeaders];
if (status == kOBEXSuccess) {
[mCurrentRequest release];
mCurrentRequest = request;
} else {
[request release];
}
return status;
}
- (OBEXError)sendSetPathRequestWithHeaders:(BBOBEXHeaderSet *)headers
changeToParentDirectoryFirst:(BOOL)changeToParentDirectoryFirst
createDirectoriesIfNeeded:(BOOL)createDirectoriesIfNeeded
{
if (mCurrentRequest && ![mCurrentRequest isFinished])
return kOBEXSessionBusyError;
BBOBEXSetPathRequest *request =
[[BBOBEXSetPathRequest alloc] initWithClient:self
eventSelector:@selector(handleSessionEvent:)
session:mSession
changeToParentDirectoryFirst:changeToParentDirectoryFirst
createDirectoriesIfNeeded:createDirectoriesIfNeeded];
BBOBEXHeaderSet *realHeaders = (mHasConnectionID ?
[self addConnectionIDToHeaders:headers] : headers);
OBEXError status = [request beginWithHeaders:realHeaders];
if (status == kOBEXSuccess) {
[mCurrentRequest release];
mCurrentRequest = request;
} else {
[request release];
}
return status;
}
- (void)abortCurrentRequest
{
if (_debug) NSLog(DEBUG_NAME @"[abortCurrentRequest]");
if (!mCurrentRequest || [mCurrentRequest isFinished] || mAborting)
return;
if (_debug) NSLog(DEBUG_NAME @"Aborting later...");
// Just set an abort flag -- can't send OBEXAbort right away because we
// might be in the middle of a transaction, and we must wait our turn to
// send the abort (i.e. wait until after we've received a server response)
mAborting = YES;
}
#pragma mark -
- (void)finishedCurrentRequestWithError:(OBEXError)error responseCode:(int)responseCode
{
if (_debug) NSLog(DEBUG_NAME @"[finishedCurrentRequestWithError] %d 0x%02x", error, responseCode);
mAborting = NO;
[mCurrentRequest finishedWithError:error responseCode:responseCode];
[mCurrentRequest release];
mCurrentRequest = nil;
}
- (void)performAbort
{
if (_debug) NSLog(DEBUG_NAME @"[performAbort]");
[mCurrentRequest release];
mCurrentRequest = [[BBOBEXAbortRequest alloc] initWithClient:self
eventSelector:@selector(handleSessionEvent:)
session:mSession];
OBEXError status = [mCurrentRequest beginWithHeaders:nil];
if (status != kOBEXSuccess)
[self finishedCurrentRequestWithError:status responseCode:0];
}
- (void)processResponseWithHeaders:(BBMutableOBEXHeaderSet *)responseHeaders
responseCode:(int)responseCode
{
if (_debug) NSLog(DEBUG_NAME @"processResponseWithHeaders 0x%x", responseCode);
if (responseCode == kOBEXResponseCodeContinueWithFinalBit) {
if (mAborting) {
[self performAbort];
return;
}
[mCurrentRequest receivedResponseWithHeaders:responseHeaders];
OBEXError status = [mCurrentRequest sendNextRequestPacket];
if (status != kOBEXSuccess) {
[self finishedCurrentRequestWithError:status responseCode:responseCode];
return;
}
} else {
[mCurrentRequest receivedResponseWithHeaders:responseHeaders];
mLastServerResponse = responseCode;
[self finishedCurrentRequestWithError:kOBEXSuccess responseCode:responseCode];
}
}
- (void)handleSessionEvent:(const OBEXSessionEvent *)event
{
if (_debug) NSLog(DEBUG_NAME @"[handleSessionEvent] event %d (current request=%@)",
event->type, mCurrentRequest);
if (mCurrentRequest) {
if (event->type == kOBEXSessionEventTypeError) {
if (_debug) NSLog(DEBUG_NAME @"[handleSessionEvent] error occurred %d", event->u.errorData.error);
[self finishedCurrentRequestWithError:event->u.errorData.error
responseCode:0];
return;
}
int responseCode;
BBMutableOBEXHeaderSet *responseHeaders = nil;
if ([mCurrentRequest readOBEXResponseHeaders:&responseHeaders
andResponseCode:&responseCode
fromSessionEvent:event]) {
if (!responseHeaders)
responseHeaders = [BBMutableOBEXHeaderSet headerSet];
if (event->type == kOBEXSessionEventTypeConnectCommandResponseReceived) {
// note any received connection id so it can be sent with later
// requests
if ([responseHeaders containsValueForHeader:kOBEXHeaderIDConnectionID]) {
mConnectionID = [responseHeaders valueForConnectionIDHeader];
mHasConnectionID = YES;
}
} else if (event->type == kOBEXSessionEventTypeDisconnectCommandResponseReceived) {
// disconnected, can clear connection id now
mConnectionID = 0;
mHasConnectionID = NO;
}
[self processResponseWithHeaders:responseHeaders
responseCode:responseCode];
} else {
// unable to read response / response didn't match current request
if (_debug) NSLog(DEBUG_NAME @"[handleSessionEvent] can't parse event!");
[self finishedCurrentRequestWithError:kOBEXSessionBadResponseError
responseCode:0];
}
} else {
if (_debug) NSLog(DEBUG_NAME @"ignoring event received while idle: %d",
event->type);
}
}
- (int)serverResponseForLastRequest
{
return mLastServerResponse;
}
// for internal testing
- (void)setOBEXSession:(OBEXSession *)session
{
[session retain];
[mSession release];
mSession = session;
}
- (BOOL)isConnected
{
if (mSession)
return [mSession hasOpenOBEXConnection];
return NO;
}
- (IOBluetoothRFCOMMChannel *)RFCOMMChannel
{
if (mSession && [mSession isKindOfClass:[IOBluetoothOBEXSession class]]) {
IOBluetoothOBEXSession *session = (IOBluetoothOBEXSession *)mSession;
return [session getRFCOMMChannel];
}
return nil;
}
- (uint32_t)connectionID
{
return mConnectionID;
}
- (BOOL)hasConnectionID
{
return mHasConnectionID;
}
- (OBEXMaxPacketLength)maximumPacketLength
{
return mMaxPacketLength;
}
- (void)setDelegate:(id)delegate
{
mDelegate = delegate;
}
- (id)delegate
{
return mDelegate;
}
+ (void)setDebug:(BOOL)debug
{
_debug = debug;
[BBOBEXRequest setDebug:debug];
}
- (void)dealloc
{
[mSession setEventSelector:NULL target:nil refCon:NULL];
[mCurrentRequest release];
mCurrentRequest = nil; // if client is deleted during a delegate callback
[mSession closeTransportConnection];
[mSession release];
mSession = nil;
[super dealloc];
}
@end
| 12,392 | BBBluetoothOBEXClient | m | en | limbo | code | {"qsc_code_num_words": 888, "qsc_code_num_chars": 12392.0, "qsc_code_mean_word_length": 8.88400901, "qsc_code_frac_words_unique": 0.30968468, "qsc_code_frac_chars_top_2grams": 0.01140829, "qsc_code_frac_chars_top_3grams": 0.01368995, "qsc_code_frac_chars_top_4grams": 0.01939409, "qsc_code_frac_chars_dupe_5grams": 0.30979845, "qsc_code_frac_chars_dupe_6grams": 0.29585499, "qsc_code_frac_chars_dupe_7grams": 0.24768665, "qsc_code_frac_chars_dupe_8grams": 0.22917987, "qsc_code_frac_chars_dupe_9grams": 0.15489923, "qsc_code_frac_chars_dupe_10grams": 0.15489923, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00235215, "qsc_code_frac_chars_whitespace": 0.27953518, "qsc_code_size_file_byte": 12392.0, "qsc_code_num_lines": 375.0, "qsc_code_num_chars_line_max": 111.0, "qsc_code_num_chars_line_mean": 33.04533333, "qsc_code_frac_chars_alphabet": 0.8812724, "qsc_code_frac_chars_comments": 0.02735636, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.30163934, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.02414337, "qsc_code_frac_chars_long_word_length": 0.00663735, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0004978, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/curses/Stench.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Stench extends Armor.Glyph {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
if ( Random.Int( 8 ) == 0) {
GameScene.add( Blob.seed( defender.pos, 250, ToxicGas.class ) );
}
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
@Override
public boolean curse() {
return true;
}
}
| 1,749 | Stench | java | en | java | code | {"qsc_code_num_words": 228, "qsc_code_num_chars": 1749.0, "qsc_code_mean_word_length": 5.86403509, "qsc_code_frac_words_unique": 0.54385965, "qsc_code_frac_chars_top_2grams": 0.08900524, "qsc_code_frac_chars_top_3grams": 0.19895288, "qsc_code_frac_chars_top_4grams": 0.19745699, "qsc_code_frac_chars_dupe_5grams": 0.25280479, "qsc_code_frac_chars_dupe_6grams": 0.12415856, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01958136, "qsc_code_frac_chars_whitespace": 0.15323042, "qsc_code_size_file_byte": 1749.0, "qsc_code_num_lines": 56.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 31.23214286, "qsc_code_frac_chars_alphabet": 0.88318704, "qsc_code_frac_chars_comments": 0.44654088, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.11538462, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00826446, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.07692308, "qsc_codejava_score_lines_no_logic": 0.5, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/curses/Corrosion.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Ooze;
import com.shatteredpixel.shatteredpixeldungeon.effects.Splash;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
public class Corrosion extends Armor.Glyph {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
if (Random.Int(10) == 0){
int pos = defender.pos;
for (int i : PathFinder.NEIGHBOURS9){
Splash.at(pos+i, 0x000000, 5);
if (Actor.findChar(pos+i) != null)
Buff.affect(Actor.findChar(pos+i), Ooze.class).set( 20f );
}
}
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
@Override
public boolean curse() {
return true;
}
}
| 1,983 | Corrosion | java | en | java | code | {"qsc_code_num_words": 261, "qsc_code_num_chars": 1983.0, "qsc_code_mean_word_length": 5.76628352, "qsc_code_frac_words_unique": 0.50191571, "qsc_code_frac_chars_top_2grams": 0.0538206, "qsc_code_frac_chars_top_3grams": 0.20199336, "qsc_code_frac_chars_top_4grams": 0.20465116, "qsc_code_frac_chars_dupe_5grams": 0.25780731, "qsc_code_frac_chars_dupe_6grams": 0.110299, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02256532, "qsc_code_frac_chars_whitespace": 0.15078164, "qsc_code_size_file_byte": 1983.0, "qsc_code_num_lines": 61.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 32.50819672, "qsc_code_frac_chars_alphabet": 0.87114014, "qsc_code_frac_chars_comments": 0.39384771, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.09090909, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.01331115, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.06060606, "qsc_codejava_score_lines_no_logic": 0.45454545, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00JCIV00/cova | docs/guides/parsing_analysis/parsing.md | # Parsing
Parsing is handled by the `cova.parseArgs`() function. It takes in a pointer to an ArgIterator (`args`), a Command type (`CommandT`), a pointer to an initialized Command (`cmd`), a Writer (`writer`), and a ParseConfig (`parse_config`), then parses each argument token sequentially. The results of a successful parse are stored in the provided Command (`cmd`) which can then be analyzed by the library user's project code.
Notably, the `cova.parseArgs`() function can return several errorrs, most of which (especially `error.UsageHelpCalled`) can be safely ignored when using the default behavior. This is demonstrated below.
## Default Setup
For the default setup, all that's needed is a pointer to an initialized `cova.ArgIteratorGeneric` (`&args_iter`), the project's Command Type (`CommandT`), a pointer to an initialized Command (`&main_cmd`), a Writer to stdout (`stdout`), and the default `ParseConfig` (`.{}`) as shown here:
```zig
const cova = @import("cova");
// Command Type
const CommandT = cova.Command.Custom(.{});
// Comptime Setup Command
const setup_cmd: CommandT = .{ ... };
pub fn main() !void {
// Allocator
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const alloc = arena.allocator();
// Command
// Note, the Command Type and `setup_cmd` are created during comptime before the `main()` function.
const main_cmd = try setup_cmd.init(alloc, .{});
defer main_cmd.deinit();
// Argument Iterator
var args_iter = try cova.ArgIteratorGeneric.init(alloc);
defer args_iter.deinit();
// Writer to stdout
const stdout = std.io.getStdOut().writer();
// Parse Function
cova.parseArgs(&args_iter, CommandT, &main_cmd, stdout, .{}) catch |err| switch (err) {
error.UsageHelpCalled,
else => return err,
};
}
```
## Custom Setup
### Choosing an ArgIterator
There are two implementations to choose from within `cova.ArgIteratorGeneric`: `.zig` and `.raw`.
- `.zig`: This implementation uses a `std.process.ArgIterator`, which is the default, cross-platform ArgIterator for Zig. It should be the most common choice for normal argument token parsing since it pulls the argument string from the process and tokenizes it into iterable arguments. Setup is handled by the `.init()` method as shown above.
- `.raw`: This implementation uses the `cova.RawArgIterator` and is intended for testing, but can also be useful parsing externally sourced argument tokens. "Externally sourced" meaning argument tokens that aren't provided by the process from the OS or Shell when the project application is run. It's set up as follows:
```zig
const test_args: []const [:0]const u8 = &.{ "test-cmd", "--string", "opt string 1", "-s", "opt string 2", "--int=1,22,333,444,555,666", "--flo", "f10.1,20.2,30.3", "-t", "val string", "sub-test-cmd", "--sub-s=sub_opt_str", "--sub-int", "21523", "help" };
var raw_iter = RawArgIterator{ .args = test_args };
var test_iter = ArgIteratorGeneric.from(raw_iter);
try parseArgs(&test_iter...);
```
#### Tokenization
As mentioned, the `std.process.ArgIterator` tokenizes its arguments automatically. However, if the `cova.RawArgIterator` is needed, then the `cova.tokenizeArgs`() function can be used to convert an argument string (`[]const u8`) into a slice of argument token strings (`[]const []const u8`). This slice can then be provided to `cova.RawArgIterator`. The `cova.TokenizeConfig` can be used to configure how the argument string is tokenized. Example:
```zig
var arena = std.heap.ArenaAllocator.init(testing.allocator);
defer arena.deinit();
const alloc = arena.allocator();
const arg_str = "cova struct-cmd --multi-str \"demo str\" -m 'a \"quoted string\"' -m \"A string using an 'apostrophe'\" 50";
const test_args = try tokenizeArgs(arg_str, alloc, .{});
```
### Creating a Command Type and a Command
As described above, the parsing process relies on the creation of a Command Type and a main Command. The specifics for this can be found under `cova.Command` in the API and the [Command Guide](../arg_types/command) in the Guides.
The basic steps are:
1. Configure a Command Type.
2. Create a comptime-known Command.
3. Initialize the comptime-known Command for runtime-use.
### Setting up a Writer
The Writer is used to output Usage/Help messages to the end user in the event of an error during parsing. The standard is to use a Writer to `stdout` or `stderr` for this as shown above. However, a Writer to a different file can also be used to avoid outputting to the end user as shown here:
```zig
var arena = std.heap.ArenaAllocator.init(testing.allocator);
defer arena.deinit();
const alloc = arena.allocator();
var writer_list = std.ArrayList(u8).init(alloc);
defer writer_list.deinit();
const writer = writer_list.writer();
```
### Parsing Configuration
The `cova.ParseConfig` allows for several configurations pertaining to how argument tokens are parsed.
### Custom Parsing & Validation Functions
#### Parsing Functions
Values and, by extension, Options can be given custom functions for parsing from an argument token to the Value's Child Type. These functions will take precedence over the default parsing and can be given at two levels, directly to the Value and to all Value's with a specific Child Type. Regardless of which level these functions are provided at, they must follow the same general structure. The first parameters must be a `[]const u8` for the argument token and the second must be a `std.mem.Allocator` that will be provided by Cova based on the Allocator given during Command Initialization (though this can be skipped using `_: std.mem.Allocator`). Finally, the Return Type must be an Error Union with the Value's Child Type.
1. `Value.Typed.parse_fn` is the field used to provide a parsing function directly to a Value as it's being set up. This function has the highest priority and is used as follows:
```zig
//Within a Command
.vals = &.{
ValueT.ofType(bool, .{
.name = "pos_or_neg",
.description = "An example boolean that must be set as 'positive' or 'negative'.",
.parse_fn = struct{
pub fn parseBool(arg: []const u8, _: std.mem.Allocator) !bool {
if (std.ascii.eqlIgnoreCase(arg, "positive") return true;
if (std.ascii.eqlIgnoreCase(arg, "negative") return false;
else return error.BoolParseError;
}
}.parseBool,
}),
},
```
2. `Value.Config.child_type_parse_fn` is the field used to provide a parsing function to all Value's that have a specific Child Type. These functions rank second in priority, behind `Value.Typed.parse_fn` but ahead of the default parsing. An example can be seen [here](../arg_types/value.md#adding-custom-child-types).
#### Validation Functions
Validation Functions are set up very similarly to Parsing Functions. They differ in that they're used to validate a Value after it's been parsed to its Child Type. As such, their structure differs by requiring the first parameter to be an instance of the Value's Child Type and the Return Type to be an Error Union with a Boolean. Notably, these functions can only be applied directly to a Value.
Example:
```zig
// Within a Command
.opts = &.{
.{
.name = "verbosity_opt",
.description = "Set the CovaDemo verbosity level. (WIP)",
.short_name = 'v',
.long_name = "verbosity",
.val = ValueT.ofType(u4, .{
.name = "verbosity_level",
.description = "The verbosity level from 0 (err) to 3 (debug).",
.default_val = 3,
.valid_fn = struct{ fn valFn(val: u4, _: mem.Allocator) bool { return val >= 1 and val <= 3; } }.valFn,
}),
},
},
```
| 7,750 | parsing | md | en | markdown | text | {"qsc_doc_frac_chars_curly_bracket": 0.00490323, "qsc_doc_frac_words_redpajama_stop": 0.24774504, "qsc_doc_num_sentences": 153.0, "qsc_doc_num_words": 1153, "qsc_doc_num_chars": 7750.0, "qsc_doc_num_lines": 132.0, "qsc_doc_mean_word_length": 4.76062446, "qsc_doc_frac_words_full_bracket": 0.0, "qsc_doc_frac_lines_end_with_readmore": 0.0, "qsc_doc_frac_lines_start_with_bullet": 0.0, "qsc_doc_frac_words_unique": 0.28707719, "qsc_doc_entropy_unigram": 5.21275611, "qsc_doc_frac_words_all_caps": 0.00240529, "qsc_doc_frac_lines_dupe_lines": 0.24324324, "qsc_doc_frac_chars_dupe_lines": 0.04740437, "qsc_doc_frac_chars_top_2grams": 0.0072873, "qsc_doc_frac_chars_top_3grams": 0.0072873, "qsc_doc_frac_chars_top_4grams": 0.00874476, "qsc_doc_frac_chars_dupe_5grams": 0.1189652, "qsc_doc_frac_chars_dupe_6grams": 0.08307524, "qsc_doc_frac_chars_dupe_7grams": 0.07706322, "qsc_doc_frac_chars_dupe_8grams": 0.07706322, "qsc_doc_frac_chars_dupe_9grams": 0.06813627, "qsc_doc_frac_chars_dupe_10grams": 0.05028238, "qsc_doc_frac_chars_replacement_symbols": 0.0, "qsc_doc_cate_code_related_file_name": 0.0, "qsc_doc_num_chars_sentence_length_mean": 24.83666667, "qsc_doc_frac_chars_hyperlink_html_tag": 0.0, "qsc_doc_frac_chars_alphabet": 0.85473982, "qsc_doc_frac_chars_digital": 0.00817482, "qsc_doc_frac_chars_whitespace": 0.17922581, "qsc_doc_frac_chars_hex_words": 0.0} | 1 | {"qsc_doc_frac_chars_replacement_symbols": 0, "qsc_doc_entropy_unigram": 0, "qsc_doc_frac_chars_top_2grams": 0, "qsc_doc_frac_chars_top_3grams": 0, "qsc_doc_frac_chars_top_4grams": 0, "qsc_doc_frac_chars_dupe_5grams": 0, "qsc_doc_frac_chars_dupe_6grams": 0, "qsc_doc_frac_chars_dupe_7grams": 0, "qsc_doc_frac_chars_dupe_8grams": 0, "qsc_doc_frac_chars_dupe_9grams": 0, "qsc_doc_frac_chars_dupe_10grams": 0, "qsc_doc_frac_chars_dupe_lines": 0, "qsc_doc_frac_lines_dupe_lines": 0, "qsc_doc_frac_lines_end_with_readmore": 0, "qsc_doc_frac_lines_start_with_bullet": 0, "qsc_doc_frac_words_all_caps": 0, "qsc_doc_mean_word_length": 0, "qsc_doc_num_chars": 0, "qsc_doc_num_lines": 0, "qsc_doc_num_sentences": 0, "qsc_doc_num_words": 0, "qsc_doc_frac_chars_hex_words": 0, "qsc_doc_frac_chars_hyperlink_html_tag": 0, "qsc_doc_frac_chars_alphabet": 0, "qsc_doc_frac_chars_digital": 0, "qsc_doc_frac_chars_whitespace": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/BattleAxe.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class BattleAxe extends MeleeWeapon {
{
image = ItemSpriteSheet.BATTLE_AXE;
tier = 4;
ACC = 1.24f; //24% boost to accuracy
}
@Override
public int max(int lvl) {
return 4*(tier+1) + //20 base, down from 25
lvl*(tier+1); //scaling unchanged
}
}
| 1,203 | BattleAxe | java | en | java | code | {"qsc_code_num_words": 172, "qsc_code_num_chars": 1203.0, "qsc_code_mean_word_length": 5.09883721, "qsc_code_frac_words_unique": 0.6744186, "qsc_code_frac_chars_top_2grams": 0.03762828, "qsc_code_frac_chars_top_3grams": 0.04446978, "qsc_code_frac_chars_top_4grams": 0.0649943, "qsc_code_frac_chars_dupe_5grams": 0.09350057, "qsc_code_frac_chars_dupe_6grams": 0.06385405, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.03080082, "qsc_code_frac_chars_whitespace": 0.19035744, "qsc_code_size_file_byte": 1203.0, "qsc_code_num_lines": 40.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 30.075, "qsc_code_frac_chars_alphabet": 0.86960986, "qsc_code_frac_chars_comments": 0.7032419, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.07142857, "qsc_codejava_score_lines_no_logic": 0.21428571, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00JCIV00/cova | docs/guides/parsing_analysis/arg_groups.md | # Argument Groups
Argument Groups can be used to organize Arguments based on similarities between them. For instance Commands might be organized into different categories for what they do while Options and Values can be grouped based on the kind of data they provide. These groups will be validated during the initialization to ensure that each group assigned to an Argument exists within the respective Group List for that Argument's parent Command.
Example:
```zig
pub const setup_cmd: CommandT = .{
.name = "covademo",
.description = "A demo of the Cova command line argument parser.",
.cmd_groups = &.{ "RAW", "STRUCT-BASED", "FN-BASED" },
.opt_groups = &.{ "INT", "BOOL", "STRING" },
.val_groups = &.{ "INT", "BOOL", "STRING" },
.sub_cmds_mandatory = false,
.mandatory_opt_groups = &.{ "BOOL" },
.sub_cmds = &.{
.{
.name = "sub-cmd",
.description = "A demo sub command.",
.cmd_group = "RAW",
},
.{
.name = "basic",
.description = "The most basic Command.",
.cmd_group = "RAW",
},
CommandT.from(DemoStruct, .{
.cmd_name = "struct-cmd",
.cmd_description = "A demo sub command made from a struct.",
.cmd_group = "STRUCT-BASED",
}),
CommandT.from(DemoUnion, .{
.cmd_name = "union-cmd",
.cmd_description = "A demo sub command made from a union.",
.cmd_group = "STRUCT-BASED",
}),
CommandT.from(@TypeOf(demoFn), .{
.cmd_name = "fn-cmd",
.cmd_description = "A demo sub command made from a function.",
.cmd_group = "FN-BASED",
}),
CommandT.from(ex_structs.add_user, .{
.cmd_name = "add-user",
.cmd_description = "A demo sub command for adding a user.",
.cmd_group = "STRUCT-BASED",
}),
},
.opts = &.{
.{
.name = "string_opt",
.description = "A string option. (Can be given up to 4 times.)",
.opt_group = "STRING",
.short_name = 's',
.long_name = "string",
.val = ValueT.ofType([]const u8, .{}),
},
.{
.name = "int_opt",
.description = "An integer option. (Can be given up to 10 times.)",
.opt_group = "INT",
.short_name = 'i',
.long_name = "int",
.val = ValueT.ofType(i16, .{}),
},
},
.vals = &.{
ValueT.ofType([]const u8, .{
.name = "cmd_str",
.description = "A string value for the command.",
.val_group = "STRING",
}),
ValueT.ofType(bool, .{
.name = "cmd_bool",
.description = "A boolean value for the command.",
.val_group = "BOOL",
}),
}
};
```
## Usage & Help Messages
If these groups are used, they will be shown in Usage and Help Messages. Their are two Format fields, `cova.Command.Config.group_title_fmt` and `cova.Command.Config.group_sep_fmt`, that can be used to customize how the groups are displayed.
## Parsing
Argument Groups can be used to mandate certain groups of Options are used by setting the `cova.Command.Custom.mandatory_opt_groups` field.
Example:
```zig
pub const setup_cmd: CommandT = .{
.name = "covademo",
.description = "A demo of the Cova command line argument parser.",
.opt_groups = &.{ "INT", "BOOL", "STRING" },
.mandatory_opt_groups = &.{ "BOOL" },
.opts = &.{
.{
.name = "cardinal_opt",
.description = "A cardinal number option.",
.opt_group = "INT",
.short_name = 'c',
.long_name = "cardinal",
.val = ValueT.ofType(u8, .{}),
},
.{
.name = "toggle_opt",
.description = "A toggle/boolean option.",
.opt_group = "BOOL",
.short_name = 't',
.long_name = "toggle",
},
.{
.name = "bool_opt",
.description = "A toggle/boolean option.",
.opt_group = "BOOL",
.short_name = 'b',
.long_name = "bool",
},
},
};
```
## Analysis
They can also be used to Get, Check, or Match the Values and Options of a Command. For Options, an Option Group can be passed to `cova.Command.Custom.getOpts`(), `cova.Command.Custom.checkOpt`(), or `cova.Command.Custom.matchOpt`(). For Values, a Value Group can be passed to `cova.Command.Custom.getVals`().
| 4,573 | arg_groups | md | en | markdown | text | {"qsc_doc_frac_chars_curly_bracket": 0.01224579, "qsc_doc_frac_words_redpajama_stop": 0.15384615, "qsc_doc_num_sentences": 116.0, "qsc_doc_num_words": 524, "qsc_doc_num_chars": 4573.0, "qsc_doc_num_lines": 120.0, "qsc_doc_mean_word_length": 4.66603053, "qsc_doc_frac_words_full_bracket": 0.0, "qsc_doc_frac_lines_end_with_readmore": 0.0, "qsc_doc_frac_lines_start_with_bullet": 0.0, "qsc_doc_frac_words_unique": 0.29580153, "qsc_doc_entropy_unigram": 4.49714585, "qsc_doc_frac_words_all_caps": 0.05128205, "qsc_doc_frac_lines_dupe_lines": 0.46956522, "qsc_doc_frac_chars_dupe_lines": 0.22454161, "qsc_doc_frac_chars_top_2grams": 0.06380368, "qsc_doc_frac_chars_top_3grams": 0.04580777, "qsc_doc_frac_chars_top_4grams": 0.03885481, "qsc_doc_frac_chars_dupe_5grams": 0.36278119, "qsc_doc_frac_chars_dupe_6grams": 0.30961145, "qsc_doc_frac_chars_dupe_7grams": 0.20245399, "qsc_doc_frac_chars_dupe_8grams": 0.20245399, "qsc_doc_frac_chars_dupe_9grams": 0.17382413, "qsc_doc_frac_chars_dupe_10grams": 0.17382413, "qsc_doc_frac_chars_replacement_symbols": 0.0, "qsc_doc_cate_code_related_file_name": 0.0, "qsc_doc_num_chars_sentence_length_mean": 15.75457875, "qsc_doc_frac_chars_hyperlink_html_tag": 0.0, "qsc_doc_frac_chars_alphabet": 0.78083947, "qsc_doc_frac_chars_digital": 0.00256328, "qsc_doc_frac_chars_whitespace": 0.31751585, "qsc_doc_frac_chars_hex_words": 0.0} | 1 | {"qsc_doc_frac_chars_replacement_symbols": 0, "qsc_doc_entropy_unigram": 0, "qsc_doc_frac_chars_top_2grams": 0, "qsc_doc_frac_chars_top_3grams": 0, "qsc_doc_frac_chars_top_4grams": 0, "qsc_doc_frac_chars_dupe_5grams": 0, "qsc_doc_frac_chars_dupe_6grams": 0, "qsc_doc_frac_chars_dupe_7grams": 0, "qsc_doc_frac_chars_dupe_8grams": 0, "qsc_doc_frac_chars_dupe_9grams": 0, "qsc_doc_frac_chars_dupe_10grams": 0, "qsc_doc_frac_chars_dupe_lines": 0, "qsc_doc_frac_lines_dupe_lines": 0, "qsc_doc_frac_lines_end_with_readmore": 0, "qsc_doc_frac_lines_start_with_bullet": 0, "qsc_doc_frac_words_all_caps": 0, "qsc_doc_mean_word_length": 0, "qsc_doc_num_chars": 0, "qsc_doc_num_lines": 0, "qsc_doc_num_sentences": 0, "qsc_doc_num_words": 0, "qsc_doc_frac_chars_hex_words": 0, "qsc_doc_frac_chars_hyperlink_html_tag": 0, "qsc_doc_frac_chars_alphabet": 0, "qsc_doc_frac_chars_digital": 0, "qsc_doc_frac_chars_whitespace": 0} |
00JCIV00/cova | docs/guides/parsing_analysis/aliases.md | # Aliases
Cova allows aliasing in two areas: Commands & Options and Value Child Types.
## Command & Option Aliases
Command aliases are created with the `cova.Command.Custom.alias_names` field and can be used to allow more than one name to be recognized as the same Command. Similarly, Option aliases are created with the `cova.Option.Custom.alias_long_names` field and can be used to allow more than one long name to be recognized as the same Option. These aliases are validated during initialization to ensure they don't conflict with other Commands/Options or their respective aliases.
Example:
```zig
pub const setup_cmd: CommandT = .{
.name = "covademo",
.description = "A demo of the Cova command line argument parser.",
.sub_cmds = &.{
.{
.name = "sub-cmd",
.description = "A demo sub command.",
.alias_names = &.{ "alias-cmd", "test-alias" },
}
},
.opts = &.{
.{
.name = "toggle_opt",
.description = "A toggle/boolean option.",
.short_name = 't',
.long_name = "toggle",
.alias_long_names = &.{ "switch", "bool" },
},
}
};
```
## Value Child Type Aliases
Aliases can also be created for the Child Types of Values, allowing Usage and Help messages to be changed without changing the actual underlying Type. This can be done with either `cova.Value.Typed.alias_child_type` for a single Value or `cova.Value.Config.child_type_aliases` for all Values with a specific Child Type. For instance, Values with a `[]const u8` can be changed to show `text` instead using the following set up:
```zig
pub const CommandT = cova.Command.Custom(.{
.val_config = .{
.child_type_aliases = &.{
.{
.ChildT = []const u8,
.alias = "text",
},
},
},
});
```
Or a single Value with a Child Type of `i8` can be changed to show `number` like so:
```zig
.val = ValueT.ofType(i8, .{
.name = "num_val",
.description = "A number value.",
.default_val = 42,
.alias_child_type = "number",
}),
```
| 2,124 | aliases | md | en | markdown | text | {"qsc_doc_frac_chars_curly_bracket": 0.01129944, "qsc_doc_frac_words_redpajama_stop": 0.23488372, "qsc_doc_num_sentences": 45.0, "qsc_doc_num_words": 285, "qsc_doc_num_chars": 2124.0, "qsc_doc_num_lines": 54.0, "qsc_doc_mean_word_length": 4.63859649, "qsc_doc_frac_words_full_bracket": 0.0, "qsc_doc_frac_lines_end_with_readmore": 0.0, "qsc_doc_frac_lines_start_with_bullet": 0.0, "qsc_doc_frac_words_unique": 0.40701754, "qsc_doc_entropy_unigram": 4.42155565, "qsc_doc_frac_words_all_caps": 0.00930233, "qsc_doc_frac_lines_dupe_lines": 0.32, "qsc_doc_frac_chars_dupe_lines": 0.0247117, "qsc_doc_frac_chars_top_2grams": 0.04765507, "qsc_doc_frac_chars_top_3grams": 0.03630862, "qsc_doc_frac_chars_top_4grams": 0.03177005, "qsc_doc_frac_chars_dupe_5grams": 0.1709531, "qsc_doc_frac_chars_dupe_6grams": 0.14372163, "qsc_doc_frac_chars_dupe_7grams": 0.10136157, "qsc_doc_frac_chars_dupe_8grams": 0.06051437, "qsc_doc_frac_chars_dupe_9grams": 0.06051437, "qsc_doc_frac_chars_dupe_10grams": 0.06051437, "qsc_doc_frac_chars_replacement_symbols": 0.0, "qsc_doc_cate_code_related_file_name": 0.0, "qsc_doc_num_chars_sentence_length_mean": 17.80530973, "qsc_doc_frac_chars_hyperlink_html_tag": 0.0, "qsc_doc_frac_chars_alphabet": 0.83502538, "qsc_doc_frac_chars_digital": 0.00380711, "qsc_doc_frac_chars_whitespace": 0.25800377, "qsc_doc_frac_chars_hex_words": 0.0} | 1 | {"qsc_doc_frac_chars_replacement_symbols": 0, "qsc_doc_entropy_unigram": 0, "qsc_doc_frac_chars_top_2grams": 0, "qsc_doc_frac_chars_top_3grams": 0, "qsc_doc_frac_chars_top_4grams": 0, "qsc_doc_frac_chars_dupe_5grams": 0, "qsc_doc_frac_chars_dupe_6grams": 0, "qsc_doc_frac_chars_dupe_7grams": 0, "qsc_doc_frac_chars_dupe_8grams": 0, "qsc_doc_frac_chars_dupe_9grams": 0, "qsc_doc_frac_chars_dupe_10grams": 0, "qsc_doc_frac_chars_dupe_lines": 0, "qsc_doc_frac_lines_dupe_lines": 0, "qsc_doc_frac_lines_end_with_readmore": 0, "qsc_doc_frac_lines_start_with_bullet": 0, "qsc_doc_frac_words_all_caps": 0, "qsc_doc_mean_word_length": 0, "qsc_doc_num_chars": 0, "qsc_doc_num_lines": 0, "qsc_doc_num_sentences": 0, "qsc_doc_num_words": 0, "qsc_doc_frac_chars_hex_words": 0, "qsc_doc_frac_chars_hyperlink_html_tag": 0, "qsc_doc_frac_chars_alphabet": 0, "qsc_doc_frac_chars_digital": 0, "qsc_doc_frac_chars_whitespace": 0} |
00JCIV00/cova | docs/guides/parsing_analysis/analysis.md | # Analysis
Once initialized and parsed, a Command can be analyzed. In the context of Cova, Analysis refers to dealing with the result of parsed Argument Types. This can range from simply debugging the results, to checking if an Argument Type was set, to utilizing the resulting values in a project. The Command Type has several functions and methods to make this easier, with methods for checking and matching sub-Commands being the standard starting point. Addtionally, it's possible to convert the Command into a comptime-known Struct, Union, or Function Type and use the resulting Type normally. For a more direct look, all of the sub-Arguments of a Command can also be analyzed individually.
## Checking and Matching Sub Commands
The `cova.Command.Custom.checkSubCmd`() and `cova.Command.Custom.matchSubCmd`() methods are designed to be the starting point for analysis. The check function simply returns a Boolean value based on a check of whether or not the provided Command name (`cmd_name`) is the same as the Command's active sub-Command. The match function works similarly, but will return the active sub-Command if it's matched or `null` otherwise. Chaining these methods into conditional `if/else` statements makes iterating over and analyzing all sub-Commands of each Command simple and easy, even when done recursively.
For a detailed example of these methods in action, refer to the [Basic-App](https://github.com/00JCIV00/cova/blob/main/examples/basic_app.zig) demo under the `// - Handle Parsed Commands` comment in the `main()` function.
Of note, there is also the `cova.Command.Custom.SubCommandsEnum`() method which will create an Enum of all of the sub-Commands of a given Command. Unfortunately, the Command this is called from must be comptime-known, making it cumbersome to use in all but the most basic of cases. For the time being, the check and match methods above should be preferred.
## Conversions
### To a Struct or Union
Once a Command has been initialized and parsed to, using the `cova.Command.Custom.to`() method will convert it into a struct or union of a comptime-known Struct or Union Type. The function takes a valid comptime-known Struct or Union Type (`ToT`) and a ToConfig (`to_config`). Details for the method, including the rules for a valid Struct or Union Type, can be found under `cova.Command.Custom.to`(). Once sucessfully created, the new struct or union can be used normally throughout the rest of the project. This process looks as follows:
```zig
const DemoStruct {
// Valid field values
...
};
...
pub fn main() !void {
...
const main_cmd = ...;
// Parse into the initialized Command
...
// Convert to struct
const demo_struct = main_cmd.to(DemoStruct, .{});
// Use the struct normally
some_fn(demo_struct);
}
```
The `cova.Command.Custom.ToConfig` can be used to specify how the Command will be converted to a struct.
### To a Function
Alternatively, the Command can also be called as a comptime-known function using `cova.Command.Custom.callAs`(). This method takes a function (`call_fn`), an optional self parameter for the function (`fn_self`), and the return Type of the function (`ReturnT`) to call the function using the Command's Arguments as the parameters. Example:
```zig
pub fn projectFn(some: anytype, params: []const u8) void {
_ = some;
_ = params;
}
...
pub fn main() !void {
...
const main_cmd = ...;
// Parse into the initialized Command
...
// Call as a Function
main_cmd.callAs(projectFn, null, void);
}
```
## Checking and Matching Options
There are a few ways to analyze Options as well, which include the `cova.Command.Custom.checkOpts`() and `cova.Command.Custom.matchOpts`() methods. These work similarly to their sub-Command counterparts detailed above. Additionally, the `cova.Command.Custom.OptionsCheckConfig` can be passed to these methods to change the kind of boolean logic they use.
## Direct Access
To directly access the sub-Argument of a Command the following fields and methods of `cova.Command.Custom` can be used:
### Fields
- `sub_cmd`: Access the sub Command of this Command if set.
- `opts`: Access the Options of this Command if any.
- `vals`: Access the Values of this Command if any.
### Methods
- `checkFlag()`: Check if a Command or Boolean Option/Value is set for this Command.
- `getOpts()` / `getOptsAlloc`: Get a String Hashmap of all of the Options in this Command as `<Name, Option>`.
- `getVals()` / `getValsAlloc`: Get a String Hashmap of all of the Values in this Command as `<Name, Value>`.
### Examples
Check the `cova.utils.displayCmdInfo`() and `cova.utils.displayValInfo`() functions for examples of direct access.
| 4,723 | analysis | md | en | markdown | text | {"qsc_doc_frac_chars_curly_bracket": 0.0021173, "qsc_doc_frac_words_redpajama_stop": 0.32929293, "qsc_doc_num_sentences": 82.0, "qsc_doc_num_words": 739, "qsc_doc_num_chars": 4723.0, "qsc_doc_num_lines": 77.0, "qsc_doc_mean_word_length": 4.7699594, "qsc_doc_frac_words_full_bracket": 0.0, "qsc_doc_frac_lines_end_with_readmore": 0.09090909, "qsc_doc_frac_lines_start_with_bullet": 0.0, "qsc_doc_frac_words_unique": 0.31935047, "qsc_doc_entropy_unigram": 4.78907932, "qsc_doc_frac_words_all_caps": 0.0010101, "qsc_doc_frac_lines_dupe_lines": 0.34482759, "qsc_doc_frac_chars_dupe_lines": 0.0437541, "qsc_doc_frac_chars_top_2grams": 0.03432624, "qsc_doc_frac_chars_top_3grams": 0.05304965, "qsc_doc_frac_chars_top_4grams": 0.03404255, "qsc_doc_frac_chars_dupe_5grams": 0.10156028, "qsc_doc_frac_chars_dupe_6grams": 0.0635461, "qsc_doc_frac_chars_dupe_7grams": 0.04652482, "qsc_doc_frac_chars_dupe_8grams": 0.04652482, "qsc_doc_frac_chars_dupe_9grams": 0.03120567, "qsc_doc_frac_chars_dupe_10grams": 0.03120567, "qsc_doc_frac_chars_replacement_symbols": 0.0, "qsc_doc_cate_code_related_file_name": 0.0, "qsc_doc_num_chars_sentence_length_mean": 25.39106145, "qsc_doc_frac_chars_hyperlink_html_tag": 0.0199026, "qsc_doc_frac_chars_alphabet": 0.89750127, "qsc_doc_frac_chars_digital": 0.00127486, "qsc_doc_frac_chars_whitespace": 0.1695956, "qsc_doc_frac_chars_hex_words": 0.0} | 1 | {"qsc_doc_frac_chars_replacement_symbols": 0, "qsc_doc_entropy_unigram": 0, "qsc_doc_frac_chars_top_2grams": 0, "qsc_doc_frac_chars_top_3grams": 0, "qsc_doc_frac_chars_top_4grams": 0, "qsc_doc_frac_chars_dupe_5grams": 0, "qsc_doc_frac_chars_dupe_6grams": 0, "qsc_doc_frac_chars_dupe_7grams": 0, "qsc_doc_frac_chars_dupe_8grams": 0, "qsc_doc_frac_chars_dupe_9grams": 0, "qsc_doc_frac_chars_dupe_10grams": 0, "qsc_doc_frac_chars_dupe_lines": 0, "qsc_doc_frac_lines_dupe_lines": 0, "qsc_doc_frac_lines_end_with_readmore": 0, "qsc_doc_frac_lines_start_with_bullet": 0, "qsc_doc_frac_words_all_caps": 0, "qsc_doc_mean_word_length": 0, "qsc_doc_num_chars": 0, "qsc_doc_num_lines": 0, "qsc_doc_num_sentences": 0, "qsc_doc_num_words": 0, "qsc_doc_frac_chars_hex_words": 0, "qsc_doc_frac_chars_hyperlink_html_tag": 0, "qsc_doc_frac_chars_alphabet": 0, "qsc_doc_frac_chars_digital": 0, "qsc_doc_frac_chars_whitespace": 0} |
00JCIV00/cova | docs/guides/getting_started/install.md | # Install
## Package Manager
1. Find the latest `v#.#.#` commit [here](https://github.com/00JCIV00/cova/commits/main).
2. Copy the full SHA for the commit.
3. Add the dependency to `build.zig.zon`:
```bash
zig fetch --save "https://github.com/00JCIV00/cova/archive/<GIT COMMIT SHA FROM STEP 2 HERE>.tar.gz"
```
4. Add the dependency and module to `build.zig`:
```zig
// Cova Dependency
const cova_dep = b.dependency("cova", .{ .target = target });
// Cova Module
const cova_mod = cova_dep.module("cova");
// Executable
const exe = b.addExecutable(.{
.name = "cova_example",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
// Add the Cova Module to the Executable
exe.root_module.addImport("cova", cova_mod);
```
## Package Manager - Alternative
Note, this method makes Cova easier to update by simply re-running `zig fetch --save https://github.com/00JCIV00/cova/archive/[BRANCH].tar.gz`. However, it can lead to non-reproducible builds because the url will always point to the newest commit of the provided branch. Details can be found in [this discussion](https://ziggit.dev/t/feature-or-bug-w-zig-fetch-save/2565).
1. Choose a branch to stay in sync with.
- `main` is the latest stable branch.
- The highest `v#.#.#` is the development branch.
2. Add the dependency to `build.zig.zon`:
```shell
zig fetch --save https://github.com/00JCIV00/cova/archive/[BRANCH FROM STEP 1].tar.gz
```
3. Continue from Step 4 above.
## Build the Basic-App Demo from source
1. Use Zig v0.12 for your system. Available [here](https://ziglang.org/download/).
2. Run the following in whichever directory you'd like to install to:
```
git clone https://github.com/00JCIV00/cova.git
cd cova
zig build basic-app -Doptimize=ReleaseSafe
```
3. Try it out!
```
cd bin
./basic-app help
```
| 1,834 | install | md | en | markdown | text | {"qsc_doc_frac_chars_curly_bracket": 0.00327154, "qsc_doc_frac_words_redpajama_stop": 0.16086957, "qsc_doc_num_sentences": 58.0, "qsc_doc_num_words": 293, "qsc_doc_num_chars": 1834.0, "qsc_doc_num_lines": 50.0, "qsc_doc_mean_word_length": 4.41979522, "qsc_doc_frac_words_full_bracket": 0.0, "qsc_doc_frac_lines_end_with_readmore": 0.0, "qsc_doc_frac_lines_start_with_bullet": 0.0, "qsc_doc_frac_words_unique": 0.46757679, "qsc_doc_entropy_unigram": 4.54414594, "qsc_doc_frac_words_all_caps": 0.03478261, "qsc_doc_frac_lines_dupe_lines": 0.14893617, "qsc_doc_frac_chars_dupe_lines": 0.01191151, "qsc_doc_frac_chars_top_2grams": 0.04247104, "qsc_doc_frac_chars_top_3grams": 0.05405405, "qsc_doc_frac_chars_top_4grams": 0.08494208, "qsc_doc_frac_chars_dupe_5grams": 0.1984556, "qsc_doc_frac_chars_dupe_6grams": 0.15830116, "qsc_doc_frac_chars_dupe_7grams": 0.15830116, "qsc_doc_frac_chars_dupe_8grams": 0.11351351, "qsc_doc_frac_chars_dupe_9grams": 0.11351351, "qsc_doc_frac_chars_dupe_10grams": 0.07876448, "qsc_doc_frac_chars_replacement_symbols": 0.0, "qsc_doc_cate_code_related_file_name": 0.0, "qsc_doc_num_chars_sentence_length_mean": 15.23893805, "qsc_doc_frac_chars_hyperlink_html_tag": 0.09269357, "qsc_doc_frac_chars_alphabet": 0.80038265, "qsc_doc_frac_chars_digital": 0.0255102, "qsc_doc_frac_chars_whitespace": 0.14503817, "qsc_doc_frac_chars_hex_words": 0.0} | 1 | {"qsc_doc_frac_chars_replacement_symbols": 0, "qsc_doc_entropy_unigram": 0, "qsc_doc_frac_chars_top_2grams": 0, "qsc_doc_frac_chars_top_3grams": 0, "qsc_doc_frac_chars_top_4grams": 0, "qsc_doc_frac_chars_dupe_5grams": 0, "qsc_doc_frac_chars_dupe_6grams": 0, "qsc_doc_frac_chars_dupe_7grams": 0, "qsc_doc_frac_chars_dupe_8grams": 0, "qsc_doc_frac_chars_dupe_9grams": 0, "qsc_doc_frac_chars_dupe_10grams": 0, "qsc_doc_frac_chars_dupe_lines": 0, "qsc_doc_frac_lines_dupe_lines": 0, "qsc_doc_frac_lines_end_with_readmore": 0, "qsc_doc_frac_lines_start_with_bullet": 0, "qsc_doc_frac_words_all_caps": 0, "qsc_doc_mean_word_length": 0, "qsc_doc_num_chars": 0, "qsc_doc_num_lines": 0, "qsc_doc_num_sentences": 0, "qsc_doc_num_words": 0, "qsc_doc_frac_chars_hex_words": 0, "qsc_doc_frac_chars_hyperlink_html_tag": 0, "qsc_doc_frac_chars_alphabet": 0, "qsc_doc_frac_chars_digital": 0, "qsc_doc_frac_chars_whitespace": 0} |
00JCIV00/cova | docs/guides/getting_started/quick_setup.md | # Quick Setup
- This is a minimum working demo of Cova integrated into a project.
```zig
const std = @import("std");
const cova = @import("cova");
const CommandT = cova.Command.Base();
pub const ProjectStruct = struct {
pub const SubStruct = struct {
sub_uint: ?u8 = 5,
sub_string: []const u8,
},
subcmd: SubStruct = .{},
int: ?i4 = 10,
flag: ?bool = false,
strings: [3]const []const u8 = .{ "Three", "default", "strings." },
};
const setup_cmd = CommandT.from(ProjectStruct);
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const alloc = arena.allocator();
const stdout = std.io.getStdOut().writer();
const main_cmd = try setup_cmd.init(alloc, .{});
defer main_cmd.deinit();
var args_iter = try cova.ArgIteratorGeneric.init(alloc);
defer args_iter.deinit();
cova.parseArgs(&args_iter, CommandT, &main_cmd, stdout, .{}) catch |err| switch(err) {
error.UsageHelpCalled,
else => return err,
}
try cova.utils.displayCmdInfo(CommandT, &main_cmd, alloc, stdout);
}
```
## Breakdown
This is a detailed explanation of the code above.
- Imports
```zig
...
// The main cova library module. This is added via `build.zig` & `build.zig.zon` during
// installation.
const cova = @import("cova");
// The Command Type for all Commands in this project.
const CommandT = cova.Command.Base();
...
```
- A Valid Project Struct. The rules for what makes a Valid struct and how they're converted into Commands can be found in the API Documentation under `cova.Command.Custom.from()`.
```zig
...
// This comptime struct is valid to be parsed into a cova Command.
pub const ProjectStruct = struct {
// This nested struct is also valid.
pub const SubStruct = struct {
// Optional Primitive type fields will be converted into cova Options.
// By default, Options will be given a long name and a short name based on the
// field name. (i.e. int = `-i` or `--int`)
sub_uint: ?u8 = 5,
// Primitive type fields will be converted into Values.
sub_string: []const u8,
},
// Struct fields will be converted into cova Commands.
subcmd: SubStruct = .{},
// The default values of Primitive type fields will be applied as the default value
// of the converted Option or Value.
int: ?i4 = 10,
// Optional Booleans will become cova Options that don't take a Value and are set to
// `true` simply by calling the Option's short or long name.
flag: ?bool = false,
// Arrays will be turned into Multi-Values or Multi-Options based on the array's
// child type.
strings: [3]const []const u8 = .{ "Three", "default", "strings." },
};
...
```
- Creating the Comptime Command.
```zig
...
// `from()` method will convert the above Struct into a Command.
// This must be done at Comptime for proper Validation before Initialization to memory
// for Runtime use.
const setup_cmd = CommandT.from(ProjectStruct);
...
```
- Command Validation and Initialization to memory for Runtime Use.
```zig
...
pub fn main() !void {
...
// The `init()` method of a Command instance will Validate the Command's
// Argument Types for correctness and distinct names, then it will return a
// memory allocated copy of the Command for argument token parsing and
// follow on analysis.
const main_cmd = try setup_cmd.init(alloc, .{});
defer main_cmd.deinit();
...
}
```
- Set up the Argument Iterator.
```zig
pub fn main() {
...
// The ArgIteratorGeneric is used to step through argument tokens.
// By default (using `init()`), it will provide Zig's native, cross-platform ArgIterator
// with end user argument tokens. There's also cova's RawArgIterator that can be used to
// parse any slice of strings as argument tokens.
var args_iter = try cova.ArgIteratorGeneric.init(alloc);
defer args_iter.deinit();
...
}
```
- Parse argument tokens and Display the result.
```zig
pub fn main() !void {
...
// The `parseArgs()` function will parse the provided ArgIterator's (`&args_iter`)
// tokens into Argument Types within the provided Command (`main_cmd`).
try cova.parseArgs(&args_iter, CommandT, &main_cmd, stdout, .{});
// Once parsed, the provided Command will be available for analysis by the
// project code. Using `utils.displayCmdInfo()` will create a neat display
// of the parsed Command for debugging.
try utils.displayCmdInfo(CommandT, &main_cmd, alloc, stdout);
}
```
| 4,602 | quick_setup | md | en | markdown | text | {"qsc_doc_frac_chars_curly_bracket": 0.00738809, "qsc_doc_frac_words_redpajama_stop": 0.18665276, "qsc_doc_num_sentences": 101.0, "qsc_doc_num_words": 631, "qsc_doc_num_chars": 4602.0, "qsc_doc_num_lines": 148.0, "qsc_doc_mean_word_length": 4.82567353, "qsc_doc_frac_words_full_bracket": 0.0, "qsc_doc_frac_lines_end_with_readmore": 0.08108108, "qsc_doc_frac_lines_start_with_bullet": 0.0, "qsc_doc_frac_words_unique": 0.33280507, "qsc_doc_entropy_unigram": 4.90195279, "qsc_doc_frac_words_all_caps": 0.00208551, "qsc_doc_frac_lines_dupe_lines": 0.55737705, "qsc_doc_frac_chars_dupe_lines": 0.2812726, "qsc_doc_frac_chars_top_2grams": 0.02068966, "qsc_doc_frac_chars_top_3grams": 0.01182266, "qsc_doc_frac_chars_top_4grams": 0.01280788, "qsc_doc_frac_chars_dupe_5grams": 0.28045977, "qsc_doc_frac_chars_dupe_6grams": 0.25385878, "qsc_doc_frac_chars_dupe_7grams": 0.18259442, "qsc_doc_frac_chars_dupe_8grams": 0.12807882, "qsc_doc_frac_chars_dupe_9grams": 0.07487685, "qsc_doc_frac_chars_dupe_10grams": 0.07487685, "qsc_doc_frac_chars_replacement_symbols": 0.0, "qsc_doc_cate_code_related_file_name": 0.0, "qsc_doc_num_chars_sentence_length_mean": 15.79927007, "qsc_doc_frac_chars_hyperlink_html_tag": 0.0, "qsc_doc_frac_chars_alphabet": 0.83789765, "qsc_doc_frac_chars_digital": 0.004426, "qsc_doc_frac_chars_whitespace": 0.21447197, "qsc_doc_frac_chars_hex_words": 0.0} | 1 | {"qsc_doc_frac_chars_replacement_symbols": 0, "qsc_doc_entropy_unigram": 0, "qsc_doc_frac_chars_top_2grams": 0, "qsc_doc_frac_chars_top_3grams": 0, "qsc_doc_frac_chars_top_4grams": 0, "qsc_doc_frac_chars_dupe_5grams": 0, "qsc_doc_frac_chars_dupe_6grams": 0, "qsc_doc_frac_chars_dupe_7grams": 0, "qsc_doc_frac_chars_dupe_8grams": 0, "qsc_doc_frac_chars_dupe_9grams": 0, "qsc_doc_frac_chars_dupe_10grams": 0, "qsc_doc_frac_chars_dupe_lines": 0, "qsc_doc_frac_lines_dupe_lines": 0, "qsc_doc_frac_lines_end_with_readmore": 0, "qsc_doc_frac_lines_start_with_bullet": 0, "qsc_doc_frac_words_all_caps": 0, "qsc_doc_mean_word_length": 0, "qsc_doc_num_chars": 0, "qsc_doc_num_lines": 0, "qsc_doc_num_sentences": 0, "qsc_doc_num_words": 0, "qsc_doc_frac_chars_hex_words": 0, "qsc_doc_frac_chars_hyperlink_html_tag": 0, "qsc_doc_frac_chars_alphabet": 0, "qsc_doc_frac_chars_digital": 0, "qsc_doc_frac_chars_whitespace": 0} |
00JCIV00/cova | docs/guides/getting_started/naming_conventions.md | # Naming Conventions
Cova follows Zig's naming conventions for the most part. This guide covers the few places where it deviates and certain conventions that may be peculiar in the Library and/or Guide.
## Argument Type vs Argument
The terms 'Argument Type' and 'Argument' are used throughout this guide. While the terms are related, they're not inter-changeable.
'Argument Type' refers to the Types `cova.Command.Custom`, `cova.Option.Custom`, and `cova.Value.Custom`. These are the base Types of Cova which can be configured to apply customizations to all of their respective instances. For brevity, these are also referred to as `CommandT`, `OptionT`, and `ValueT`.
Conversely, `Argument` refers to any instance of those Types, which can also be referenced individualy as a Command, Option, or Value.
## Callback Functions
Cova uses Callback Functions to allow the library user to overwrite or otherwise customize certain aspects of the argument parsing process. The functions are represented as fields within both the Argument Type Config Structs and Instances. They're always some variation of the Type `?*const fn()` (with varying parameters and Return Types) and end with the `_fn` suffix to distinguish them from both other fields and normal functions.
## Functions vs Methods
While Zig doesn't officially have methods, it does have 'Member Functions'. These are functions that belong to a Type and whose first parameter is an instance or pointer of that Type. They work effectively the same way as methods in other languages, so the term 'method' is used in this guide for both brevity and clarity.
## Global & Child Type Prefixes
Some fields are shared between both the Argument Type Config Structs and their Instances. These fields all share the purpose of overwriting some default property with varying levels of precedence as denoted by their prefixes:
1. No Prefix: These will always be found directly on the Argument they apply to and have the highest precedence. They apply only to that Argument.
2. `child_type_`: These are only found within Value Config Structs and have the 2nd highest precedence. They apply to any Values with the corresponding Child Type.
3. `global_`: These will always be found within a Config Struct and have lowest precedence. They apply to all Arguments of the configured Type.
## Title Case
Types and certain Key Concepts will be shown in Title Case for distinction. For Types, this includes their descriptions, such as 'Command Type', and their Type Names like in 'CommandT'.
## Users
This guide makes reference to both 'Library' and 'End' users. 'Library user' refers to the developer using the Cova library (probably you, the reader) and 'End user' refers to the user of an application or project built with the help of the Cova library.
| 2,796 | naming_conventions | md | en | markdown | text | {"qsc_doc_frac_chars_curly_bracket": 0.0, "qsc_doc_frac_words_redpajama_stop": 0.37837838, "qsc_doc_num_sentences": 35.0, "qsc_doc_num_words": 451, "qsc_doc_num_chars": 2796.0, "qsc_doc_num_lines": 28.0, "qsc_doc_mean_word_length": 4.89800443, "qsc_doc_frac_words_full_bracket": 0.0, "qsc_doc_frac_lines_end_with_readmore": 0.0, "qsc_doc_frac_lines_start_with_bullet": 0.0, "qsc_doc_frac_words_unique": 0.40798226, "qsc_doc_entropy_unigram": 4.75491211, "qsc_doc_frac_words_all_caps": 0.0, "qsc_doc_frac_lines_dupe_lines": 0.0, "qsc_doc_frac_chars_dupe_lines": 0.0, "qsc_doc_frac_chars_top_2grams": 0.02716161, "qsc_doc_frac_chars_top_3grams": 0.01493889, "qsc_doc_frac_chars_top_4grams": 0.01720235, "qsc_doc_frac_chars_dupe_5grams": 0.05160706, "qsc_doc_frac_chars_dupe_6grams": 0.03168855, "qsc_doc_frac_chars_dupe_7grams": 0.03168855, "qsc_doc_frac_chars_dupe_8grams": 0.0, "qsc_doc_frac_chars_dupe_9grams": 0.0, "qsc_doc_frac_chars_dupe_10grams": 0.0, "qsc_doc_frac_chars_replacement_symbols": 0.0, "qsc_doc_cate_code_related_file_name": 0.0, "qsc_doc_num_chars_sentence_length_mean": 42.703125, "qsc_doc_frac_chars_hyperlink_html_tag": 0.0, "qsc_doc_frac_chars_alphabet": 0.94271056, "qsc_doc_frac_chars_digital": 0.00171013, "qsc_doc_frac_chars_whitespace": 0.16344778, "qsc_doc_frac_chars_hex_words": 0.0} | 1 | {"qsc_doc_frac_chars_replacement_symbols": 0, "qsc_doc_entropy_unigram": 0, "qsc_doc_frac_chars_top_2grams": 0, "qsc_doc_frac_chars_top_3grams": 0, "qsc_doc_frac_chars_top_4grams": 0, "qsc_doc_frac_chars_dupe_5grams": 0, "qsc_doc_frac_chars_dupe_6grams": 0, "qsc_doc_frac_chars_dupe_7grams": 0, "qsc_doc_frac_chars_dupe_8grams": 0, "qsc_doc_frac_chars_dupe_9grams": 0, "qsc_doc_frac_chars_dupe_10grams": 0, "qsc_doc_frac_chars_dupe_lines": 0, "qsc_doc_frac_lines_dupe_lines": 0, "qsc_doc_frac_lines_end_with_readmore": 0, "qsc_doc_frac_lines_start_with_bullet": 0, "qsc_doc_frac_words_all_caps": 0, "qsc_doc_mean_word_length": 0, "qsc_doc_num_chars": 0, "qsc_doc_num_lines": 0, "qsc_doc_num_sentences": 0, "qsc_doc_num_words": 0, "qsc_doc_frac_chars_hex_words": 0, "qsc_doc_frac_chars_hyperlink_html_tag": 0, "qsc_doc_frac_chars_alphabet": 0, "qsc_doc_frac_chars_digital": 0, "qsc_doc_frac_chars_whitespace": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Longsword.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class Longsword extends MeleeWeapon {
{
image = ItemSpriteSheet.LONGSWORD;
tier = 4;
}
}
| 1,032 | Longsword | java | en | java | code | {"qsc_code_num_words": 144, "qsc_code_num_chars": 1032.0, "qsc_code_mean_word_length": 5.38194444, "qsc_code_frac_words_unique": 0.65972222, "qsc_code_frac_chars_top_2grams": 0.04258065, "qsc_code_frac_chars_top_3grams": 0.05032258, "qsc_code_frac_chars_top_4grams": 0.07354839, "qsc_code_frac_chars_dupe_5grams": 0.10580645, "qsc_code_frac_chars_dupe_6grams": 0.07225806, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02130178, "qsc_code_frac_chars_whitespace": 0.18120155, "qsc_code_size_file_byte": 1032.0, "qsc_code_num_lines": 33.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 31.27272727, "qsc_code_frac_chars_alphabet": 0.89585799, "qsc_code_frac_chars_comments": 0.75678295, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.0, "qsc_codejava_score_lines_no_logic": 0.25, "qsc_codejava_frac_words_no_modifier": 0.0, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": null, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Greatsword.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class Greatsword extends MeleeWeapon {
{
image = ItemSpriteSheet.GREATSWORD;
tier=5;
}
}
| 1,031 | Greatsword | java | en | java | code | {"qsc_code_num_words": 144, "qsc_code_num_chars": 1031.0, "qsc_code_mean_word_length": 5.39583333, "qsc_code_frac_words_unique": 0.65972222, "qsc_code_frac_chars_top_2grams": 0.04247104, "qsc_code_frac_chars_top_3grams": 0.05019305, "qsc_code_frac_chars_top_4grams": 0.07335907, "qsc_code_frac_chars_dupe_5grams": 0.10553411, "qsc_code_frac_chars_dupe_6grams": 0.07207207, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02125148, "qsc_code_frac_chars_whitespace": 0.17846751, "qsc_code_size_file_byte": 1031.0, "qsc_code_num_lines": 33.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 31.24242424, "qsc_code_frac_chars_alphabet": 0.8961039, "qsc_code_frac_chars_comments": 0.75751697, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.0, "qsc_codejava_score_lines_no_logic": 0.25, "qsc_codejava_frac_words_no_modifier": 0.0, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": null, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/HandAxe.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class HandAxe extends MeleeWeapon {
{
image = ItemSpriteSheet.HAND_AXE;
tier = 2;
ACC = 1.32f; //32% boost to accuracy
}
@Override
public int max(int lvl) {
return 4*(tier+1) + //12 base, down from 15
lvl*(tier+1); //scaling unchanged
}
}
| 1,199 | HandAxe | java | en | java | code | {"qsc_code_num_words": 172, "qsc_code_num_chars": 1199.0, "qsc_code_mean_word_length": 5.0755814, "qsc_code_frac_words_unique": 0.68023256, "qsc_code_frac_chars_top_2grams": 0.03780069, "qsc_code_frac_chars_top_3grams": 0.04467354, "qsc_code_frac_chars_top_4grams": 0.0652921, "qsc_code_frac_chars_dupe_5grams": 0.09392898, "qsc_code_frac_chars_dupe_6grams": 0.06414662, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.03092784, "qsc_code_frac_chars_whitespace": 0.19099249, "qsc_code_size_file_byte": 1199.0, "qsc_code_num_lines": 40.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 29.975, "qsc_code_frac_chars_alphabet": 0.86907216, "qsc_code_frac_chars_comments": 0.70558799, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.07142857, "qsc_codejava_score_lines_no_logic": 0.21428571, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00JCIV00/cova | examples/cova_demo_meta/help_docs/markdown/covademo-struct-cmd.md | # struct-cmd
__[covademo](./covademo.md)__ > __struct-cmd__
A demo sub command made from a struct.
___
## Usage
```shell
USAGE
struct-cmd [ --int | --str | --str2 | --flt | --int2 | --multi-int | --multi-str | --rgb-enum | --struct-bool | --struct-str | --struct-int ]
struct-cmd [ inner-cmd ]
```
## Arguments
### Commands
- [__inner-cmd__](./covademo-struct-cmd-inner-cmd.md): An inner/nested command for struct-cmd
### Options
- __int__:
- `-i, --int <int (i32)>`
- The first Integer Value for the struct-cmd.
- __str__:
- `-s, --str <str (text)>`
- The 'str' Option.
- __str2__:
- `-S, --str2 <str2 (text)>`
- The 'str2' Option.
- __flt__:
- `-f, --flt <flt (f16)>`
- The 'flt' Option.
- __int2__:
- `-I, --int2 <int2 (u16)>`
- The 'int2' Option.
- __multi-int__:
- `-m, --multi-int <multi-int (u8)>`
- The 'multi-int' Value.
- __multi-str__:
- `-M, --multi-str <multi-str (text)>`
- The 'multi-str' Value.
- __rgb-enum__:
- `-r, --rgb-enum <rgb-enum (covademo.DemoStruct.InnerEnum)>`
- The 'rgb-enum' Option.
- __struct-bool__:
- `-t, --struct-bool <struct-bool (toggle)>`
- The 'struct_bool' Option of type 'toggle'.
- __struct-str__:
- `-T, --struct-str <struct-str (text)>`
- The 'struct_str' Option of type 'text'.
- __struct-int__:
- `-R, --struct-int <struct-int (i64)>`
- The 'struct_int' Option of type 'i64'.
### Values
- __multi-int-val__ (u16)
- The 'multi-int-val' Value.
| 1,504 | covademo-struct-cmd | md | en | markdown | text | {"qsc_doc_frac_chars_curly_bracket": 0.0, "qsc_doc_frac_words_redpajama_stop": 0.043379, "qsc_doc_num_sentences": 19.0, "qsc_doc_num_words": 197, "qsc_doc_num_chars": 1504.0, "qsc_doc_num_lines": 55.0, "qsc_doc_mean_word_length": 4.07106599, "qsc_doc_frac_words_full_bracket": 0.0, "qsc_doc_frac_lines_end_with_readmore": 0.0, "qsc_doc_frac_lines_start_with_bullet": 0.0, "qsc_doc_frac_words_unique": 0.26395939, "qsc_doc_entropy_unigram": 3.46143318, "qsc_doc_frac_words_all_caps": 0.01598174, "qsc_doc_frac_lines_dupe_lines": 0.0, "qsc_doc_frac_chars_dupe_lines": 0.0, "qsc_doc_frac_chars_top_2grams": 0.07855362, "qsc_doc_frac_chars_top_3grams": 0.03740648, "qsc_doc_frac_chars_top_4grams": 0.04239401, "qsc_doc_frac_chars_dupe_5grams": 0.0, "qsc_doc_frac_chars_dupe_6grams": 0.0, "qsc_doc_frac_chars_dupe_7grams": 0.0, "qsc_doc_frac_chars_dupe_8grams": 0.0, "qsc_doc_frac_chars_dupe_9grams": 0.0, "qsc_doc_frac_chars_dupe_10grams": 0.0, "qsc_doc_frac_chars_replacement_symbols": 0.0, "qsc_doc_cate_code_related_file_name": 0.0, "qsc_doc_num_chars_sentence_length_mean": 19.06666667, "qsc_doc_frac_chars_hyperlink_html_tag": 0.12898936, "qsc_doc_frac_chars_alphabet": 0.65682968, "qsc_doc_frac_chars_digital": 0.01939292, "qsc_doc_frac_chars_whitespace": 0.21143617, "qsc_doc_frac_chars_hex_words": 0.0} | 1 | {"qsc_doc_frac_chars_replacement_symbols": 0, "qsc_doc_entropy_unigram": 0, "qsc_doc_frac_chars_top_2grams": 0, "qsc_doc_frac_chars_top_3grams": 0, "qsc_doc_frac_chars_top_4grams": 0, "qsc_doc_frac_chars_dupe_5grams": 0, "qsc_doc_frac_chars_dupe_6grams": 0, "qsc_doc_frac_chars_dupe_7grams": 0, "qsc_doc_frac_chars_dupe_8grams": 0, "qsc_doc_frac_chars_dupe_9grams": 0, "qsc_doc_frac_chars_dupe_10grams": 0, "qsc_doc_frac_chars_dupe_lines": 0, "qsc_doc_frac_lines_dupe_lines": 0, "qsc_doc_frac_lines_end_with_readmore": 0, "qsc_doc_frac_lines_start_with_bullet": 0, "qsc_doc_frac_words_all_caps": 0, "qsc_doc_mean_word_length": 0, "qsc_doc_num_chars": 0, "qsc_doc_num_lines": 0, "qsc_doc_num_sentences": 0, "qsc_doc_num_words": 0, "qsc_doc_frac_chars_hex_words": 0, "qsc_doc_frac_chars_hyperlink_html_tag": 0, "qsc_doc_frac_chars_alphabet": 0, "qsc_doc_frac_chars_digital": 0, "qsc_doc_frac_chars_whitespace": 0} |
00JCIV00/cova | examples/cova_demo_meta/help_docs/markdown/covademo.md | # covademo
A demo of the Cova command line argument parser.
__Version:__ 0.10.2<br>
__Date:__ 23 OCT 2024<br>
__Author:__ 00JCIV00<br>
__Copyright:__ MIT License<br>
___
## Usage
```shell
USAGE
covademo [ --string | --int | --float | --file | --ordinal | --cardinal | --toggle | --bool | --verbosity ]
covademo [ sub-cmd | basic | nest-1 | struct-cmd | union-cmd | fn-cmd | add-user ]
```
## Examples
- `covademo -b --string "Optional String"`
- `covademo -i 0 -i=1 -i2 -i=3,4,5 -i6,7 --int 8 --int=9`
- `covademo --file "/some/file"`
## Arguments
### Commands
- [__sub-cmd__](./covademo-sub-cmd.md): A demo sub command.
- [__basic__](./covademo-basic.md): The most basic Command.
- [__nest-1__](./covademo-nest-1.md): Nested Level 1.
- [__struct-cmd__](./covademo-struct-cmd.md): A demo sub command made from a struct.
- [__union-cmd__](./covademo-union-cmd.md): A demo sub command made from a union.
- [__fn-cmd__](./covademo-fn-cmd.md): A demo sub command made from a function.
- [__add-user__](./covademo-add-user.md): A demo sub command for adding a user.
### Options
- __string_opt__:
- `-s, --string, --text <string_val (string)>`
- A string option. (Can be given up to 4 times.)
- __int_opt__:
- `-i, --int <int_val (i16)>`
- An integer option. (Can be given up to 10 times.)
- __float_opt__:
- `-f, --float <float_val (f16)>`
- An float option. (Can be given up to 10 times.)
- __file_opt__:
- `-F, --file <filepath (filepath)>`
- A filepath option.
- __ordinal_opt__:
- `-o, --ordinal <ordinal_val (text)>`
- An ordinal number option.
- __cardinal_opt__:
- `-c, --cardinal <cardinal_val (u8)>`
- A cardinal number option.
- __toggle_opt__:
- `-t, --toggle, --switch <toggle_val (toggle)>`
- A toggle/boolean option.
- __bool_opt__:
- `-b, --bool <bool_val (toggle)>`
- A toggle/boolean option.
- __verbosity_opt__:
- `-v, --verbosity <verbosity_level (u4)>`
- Set the CovaDemo verbosity level. (WIP)
### Values
- __cmd_str__ (text)
- A string value for the command.
- __cmd_bool__ (toggle)
- A boolean value for the command.
- __cmd_u64__ (u64)
- A u64 value for the command.
| 2,198 | covademo | md | en | markdown | text | {"qsc_doc_frac_chars_curly_bracket": 0.0, "qsc_doc_frac_words_redpajama_stop": 0.09265734, "qsc_doc_num_sentences": 39.0, "qsc_doc_num_words": 313, "qsc_doc_num_chars": 2198.0, "qsc_doc_num_lines": 67.0, "qsc_doc_mean_word_length": 4.12140575, "qsc_doc_frac_words_full_bracket": 0.0, "qsc_doc_frac_lines_end_with_readmore": 0.0, "qsc_doc_frac_lines_start_with_bullet": 0.0, "qsc_doc_frac_words_unique": 0.32587859, "qsc_doc_entropy_unigram": 4.24206302, "qsc_doc_frac_words_all_caps": 0.03496503, "qsc_doc_frac_lines_dupe_lines": 0.03278689, "qsc_doc_frac_chars_dupe_lines": 0.0255027, "qsc_doc_frac_chars_top_2grams": 0.02325581, "qsc_doc_frac_chars_top_3grams": 0.02713178, "qsc_doc_frac_chars_top_4grams": 0.03875969, "qsc_doc_frac_chars_dupe_5grams": 0.23100775, "qsc_doc_frac_chars_dupe_6grams": 0.18527132, "qsc_doc_frac_chars_dupe_7grams": 0.10930233, "qsc_doc_frac_chars_dupe_8grams": 0.10930233, "qsc_doc_frac_chars_dupe_9grams": 0.06744186, "qsc_doc_frac_chars_dupe_10grams": 0.0, "qsc_doc_frac_chars_replacement_symbols": 0.0, "qsc_doc_cate_code_related_file_name": 0.0, "qsc_doc_num_chars_sentence_length_mean": 19.55140187, "qsc_doc_frac_chars_hyperlink_html_tag": 0.08689718, "qsc_doc_frac_chars_alphabet": 0.70061902, "qsc_doc_frac_chars_digital": 0.02532358, "qsc_doc_frac_chars_whitespace": 0.19153776, "qsc_doc_frac_chars_hex_words": 0.0} | 1 | {"qsc_doc_frac_chars_replacement_symbols": 0, "qsc_doc_entropy_unigram": 0, "qsc_doc_frac_chars_top_2grams": 0, "qsc_doc_frac_chars_top_3grams": 0, "qsc_doc_frac_chars_top_4grams": 0, "qsc_doc_frac_chars_dupe_5grams": 0, "qsc_doc_frac_chars_dupe_6grams": 0, "qsc_doc_frac_chars_dupe_7grams": 0, "qsc_doc_frac_chars_dupe_8grams": 0, "qsc_doc_frac_chars_dupe_9grams": 0, "qsc_doc_frac_chars_dupe_10grams": 0, "qsc_doc_frac_chars_dupe_lines": 0, "qsc_doc_frac_lines_dupe_lines": 0, "qsc_doc_frac_lines_end_with_readmore": 0, "qsc_doc_frac_lines_start_with_bullet": 0, "qsc_doc_frac_words_all_caps": 0, "qsc_doc_mean_word_length": 0, "qsc_doc_num_chars": 0, "qsc_doc_num_lines": 0, "qsc_doc_num_sentences": 0, "qsc_doc_num_words": 0, "qsc_doc_frac_chars_hex_words": 0, "qsc_doc_frac_chars_hyperlink_html_tag": 0, "qsc_doc_frac_chars_alphabet": 0, "qsc_doc_frac_chars_digital": 0, "qsc_doc_frac_chars_whitespace": 0} |
00JCIV00/cova | examples/basic_app_meta/tab_completions/basic-app-completion.ps1 | # Requires PowerShell v5.1+
# This Tab Completion script was generated by the Cova Library.
# Details at https://github.com/00JCIV00/cova
# PowerShell Completion Installation Instructions for basic-app
# 1. Load the completion script into your current PowerShell session:
# . .\basic-app-completion.ps1
#
# 2. Ensure your Execution Policy allows the script to be run. Example:
# Set-ExecutionPolicy RemoteSigned
#
# 3. To ensure this completion script is loaded automatically in future sessions,
# add the above sourcing command to your PowerShell profile:
# Notepad $PROFILE
# Add the line: . C:\path\to\basic-app-completion.ps1
#
# 4. Restart your PowerShell session or source your profile again:
# . $PROFILE
function _basic-app {
param($wordToComplete, $commandAst)
$suggestions = @(
'new',
'open',
'list',
'clean',
'view-lists',
'help',
'usage',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _basic-app-new {
param($wordToComplete, $commandAst)
$suggestions = @(
'help',
'usage',
'--first-name',
'--last-name',
'--age',
'--phone',
'--address',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _basic-app-open {
param($wordToComplete, $commandAst)
$suggestions = @(
'help',
'usage',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _basic-app-list {
param($wordToComplete, $commandAst)
$suggestions = @(
'filter',
'help',
'usage',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _basic-app-list-filter {
param($wordToComplete, $commandAst)
$suggestions = @(
'help',
'usage',
'--id',
'--admin',
'--age',
'--first-name',
'--last-name',
'--phone',
'--address',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _basic-app-clean {
param($wordToComplete, $commandAst)
$suggestions = @(
'help',
'usage',
'--file',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _basic-app-view-lists {
param($wordToComplete, $commandAst)
$suggestions = @(
'help',
'usage',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
Register-ArgumentCompleter -CommandName 'basic-app.exe' -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPos)
$functionName = "_" + $($commandAst.Extent.Text.replace(' ', '-').replace(".exe", ""))
if ($wordToComplete) {
$functionName = $functionName.replace("-$wordToComplete", "")
}
# Check if the function exists and invoke it
if (Get-Command -Name $functionName -ErrorAction SilentlyContinue) {
& $functionName $wordToComplete $commandAst
} else {
# Fallback logic to show files in the current directory
Get-ChildItem -Path '.' -File | Where-Object Name -like "*$wordToComplete*" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, 'ParameterValue', $_.Name)
}
}
} | 3,271 | basic-app-completion | ps1 | en | powershell | code | {"qsc_code_num_words": 324, "qsc_code_num_chars": 3271.0, "qsc_code_mean_word_length": 6.32716049, "qsc_code_frac_words_unique": 0.37962963, "qsc_code_frac_chars_top_2grams": 0.06146341, "qsc_code_frac_chars_top_3grams": 0.11317073, "qsc_code_frac_chars_top_4grams": 0.13658537, "qsc_code_frac_chars_dupe_5grams": 0.37853659, "qsc_code_frac_chars_dupe_6grams": 0.37853659, "qsc_code_frac_chars_dupe_7grams": 0.30682927, "qsc_code_frac_chars_dupe_8grams": 0.30682927, "qsc_code_frac_chars_dupe_9grams": 0.30682927, "qsc_code_frac_chars_dupe_10grams": 0.30682927, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0045977, "qsc_code_frac_chars_whitespace": 0.20207887, "qsc_code_size_file_byte": 3271.0, "qsc_code_num_lines": 136.0, "qsc_code_num_chars_line_max": 110.0, "qsc_code_num_chars_line_mean": 24.05147059, "qsc_code_frac_chars_alphabet": 0.78084291, "qsc_code_frac_chars_comments": 0.0, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.48360656, "qsc_code_cate_autogen": 1.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.14394866, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 1, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
00JCIV00/cova | examples/basic_app_meta/tab_completions/basic-app-completion.bash | #! /usr/bin/env bash
# This Tab Completion script was generated by the Cova Library.
# Details at https://github.com/00JCIV00/cova
# Bash Completion Installation Instructions for basic-app
# 1. Place this script in a directory like /etc/bash_completion.d/ (Linux)
# or /usr/local/etc/bash_completion.d/ (Mac, if using Homebrew and bash-completion)
#
# 2. Ensure the script has executable permissions:
# chmod +x basic-app-completion.bash
#
# 3. Source this script from your .bashrc or .bash_profile by adding:
# . /path/to/basic-app-completion.bash
#
# 4. Restart your terminal session or source your profile again:
# source ~/.bashrc # or ~/.bash_profile
_basic-app_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"new")
_basic-app_new_completions
;;
"open")
_basic-app_open_completions
;;
"list")
_basic-app_list_completions
;;
"clean")
_basic-app_clean_completions
;;
"view-lists")
_basic-app_view-lists_completions
;;
"basic-app")
COMPREPLY=($(compgen -W "new open list clean view-lists help usage --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_basic-app_new_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"new")
COMPREPLY=($(compgen -W "help usage --first-name --last-name --age --phone --address --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_basic-app_open_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"open")
COMPREPLY=($(compgen -W "help usage --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_basic-app_list_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"filter")
_basic-applist_filter_completions
;;
"list")
COMPREPLY=($(compgen -W "filter help usage --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_basic-app_list_filter_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"filter")
COMPREPLY=($(compgen -W "help usage --id --admin --age --first-name --last-name --phone --address --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_basic-app_clean_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"clean")
COMPREPLY=($(compgen -W "help usage --file --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_basic-app_view-lists_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"view-lists")
COMPREPLY=($(compgen -W "help usage --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
complete -F _basic-app_completions basic-app | 3,764 | basic-app-completion | bash | en | shell | code | {"qsc_code_num_words": 419, "qsc_code_num_chars": 3764.0, "qsc_code_mean_word_length": 4.72076372, "qsc_code_frac_words_unique": 0.22434368, "qsc_code_frac_chars_top_2grams": 0.07280081, "qsc_code_frac_chars_top_3grams": 0.09201213, "qsc_code_frac_chars_top_4grams": 0.12740142, "qsc_code_frac_chars_dupe_5grams": 0.57482305, "qsc_code_frac_chars_dupe_6grams": 0.51668352, "qsc_code_frac_chars_dupe_7grams": 0.51668352, "qsc_code_frac_chars_dupe_8grams": 0.51668352, "qsc_code_frac_chars_dupe_9grams": 0.51668352, "qsc_code_frac_chars_dupe_10grams": 0.51668352, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00562852, "qsc_code_frac_chars_whitespace": 0.29197662, "qsc_code_size_file_byte": 3764.0, "qsc_code_num_lines": 145.0, "qsc_code_num_chars_line_max": 138.0, "qsc_code_num_chars_line_mean": 25.95862069, "qsc_code_frac_chars_alphabet": 0.73658537, "qsc_code_frac_chars_comments": 0.17773645, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.75454545, "qsc_code_cate_autogen": 1.0, "qsc_code_frac_lines_long_string": 0.00909091, "qsc_code_frac_chars_string_length": 0.26841085, "qsc_code_frac_chars_long_word_length": 0.10852713, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 1, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 1, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0} |
00JCIV00/cova | examples/basic_app_meta/tab_completions/_basic-app-completion.zsh | #compdef basic-app
# This Tab Completion script was generated by the Cova Library.
# Details at https://github.com/00JCIV00/cova
# Zsh Completion Installation Instructions for basic-app
# 1. Place this script in a directory specified in your $fpath, or a new one such as
# ~/.zsh/completion/
#
# 2. Ensure the script has executable permissions:
# chmod +x _basic-app-completion.zsh
#
# 3. Add the script's directory to your $fpath in your .zshrc if not already included:
# fpath=(~/.zsh/completion $fpath)
#
# 4. Enable and initialize completion in your .zshrc if you haven't already (oh-my-zsh does this automatically):
# autoload -Uz compinit && compinit
#
# 5. Restart your terminal session or source your .zshrc again:
# source ~/.zshrc
# Associative array to hold Commands, Options, and their descriptions with arbitrary depth
typeset -A cmd_args
cmd_args=(
"basic-app" "new open list clean view-lists help usage --help --usage"
"basic-app_new" "help usage --first-name --last-name --age --phone --address --help --usage"
"basic-app_open" "help usage --help --usage"
"basic-app_list" "filter help usage --help --usage"
"basic-app_list_filter" "help usage --id --admin --age --first-name --last-name --phone --address --help --usage"
"basic-app_clean" "help usage --file --help --usage"
"basic-app_view-lists" "help usage --help --usage"
)
# Generic function for command completions
_basic-app_completions() {
local -a completions
# Determine the current command context
local context="basic-app"
for word in "${words[@]:1:$CURRENT-1}"; do
if [[ -n $cmd_args[${context}_${word}] ]]; then
context="${context}_${word}"
fi
done
# Generate completions for the current context
completions=(${(s: :)cmd_args[$context]})
if [[ -n $completions ]]; then
_describe -t commands "basic-app" completions && return 0
fi
}
_basic-app_completions "$@" | 1,959 | _basic-app-completion | zsh | en | shell | code | {"qsc_code_num_words": 273, "qsc_code_num_chars": 1959.0, "qsc_code_mean_word_length": 4.83150183, "qsc_code_frac_words_unique": 0.44322344, "qsc_code_frac_chars_top_2grams": 0.08491281, "qsc_code_frac_chars_top_3grams": 0.06368461, "qsc_code_frac_chars_top_4grams": 0.07733131, "qsc_code_frac_chars_dupe_5grams": 0.15238817, "qsc_code_frac_chars_dupe_6grams": 0.15238817, "qsc_code_frac_chars_dupe_7grams": 0.06141016, "qsc_code_frac_chars_dupe_8grams": 0.06141016, "qsc_code_frac_chars_dupe_9grams": 0.06141016, "qsc_code_frac_chars_dupe_10grams": 0.06141016, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00753769, "qsc_code_frac_chars_whitespace": 0.18734048, "qsc_code_size_file_byte": 1959.0, "qsc_code_num_lines": 51.0, "qsc_code_num_chars_line_max": 118.0, "qsc_code_num_chars_line_mean": 38.41176471, "qsc_code_frac_chars_alphabet": 0.8209799, "qsc_code_frac_chars_comments": 0.49872384, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.08333333, "qsc_code_cate_autogen": 1.0, "qsc_code_frac_lines_long_string": 0.04166667, "qsc_code_frac_chars_string_length": 0.5076297, "qsc_code_frac_chars_long_word_length": 0.04577823, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 1, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/AntiMagic.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Charm;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Weakness;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Eye;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Shaman;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Warlock;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Yog;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfDisintegration;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFireblast;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFrost;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfLightning;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfLivingEarth;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfPrismaticLight;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfTransfusion;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfWarding;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.DisintegrationTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.GrimTrap;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
import java.util.HashSet;
public class AntiMagic extends Armor.Glyph {
private static ItemSprite.Glowing TEAL = new ItemSprite.Glowing( 0x88EEFF );
public static final HashSet<Class> RESISTS = new HashSet<>();
static {
RESISTS.add( Charm.class );
RESISTS.add( Weakness.class );
RESISTS.add( DisintegrationTrap.class );
RESISTS.add( GrimTrap.class );
RESISTS.add( WandOfBlastWave.class );
RESISTS.add( WandOfDisintegration.class );
RESISTS.add( WandOfFireblast.class );
RESISTS.add( WandOfFrost.class );
RESISTS.add( WandOfLightning.class );
RESISTS.add( WandOfLivingEarth.class );
RESISTS.add( WandOfMagicMissile.class );
RESISTS.add( WandOfPrismaticLight.class );
RESISTS.add( WandOfTransfusion.class );
RESISTS.add( WandOfWarding.Ward.class );
RESISTS.add( Shaman.LightningBolt.class );
RESISTS.add( Warlock.DarkBolt.class );
RESISTS.add( Eye.DeathGaze.class );
RESISTS.add( Yog.BurningFist.DarkBolt.class );
}
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
//no proc effect, see Hero.damage
return damage;
}
public static int drRoll( int level ){
return Random.NormalIntRange(level, 4 + (level*2));
}
@Override
public ItemSprite.Glowing glowing() {
return TEAL;
}
} | 3,698 | AntiMagic | java | en | java | code | {"qsc_code_num_words": 424, "qsc_code_num_chars": 3698.0, "qsc_code_mean_word_length": 6.98820755, "qsc_code_frac_words_unique": 0.35849057, "qsc_code_frac_chars_top_2grams": 0.12622342, "qsc_code_frac_chars_top_3grams": 0.28214647, "qsc_code_frac_chars_top_4grams": 0.3118461, "qsc_code_frac_chars_dupe_5grams": 0.4083699, "qsc_code_frac_chars_dupe_6grams": 0.34829565, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00667071, "qsc_code_frac_chars_whitespace": 0.10816658, "qsc_code_size_file_byte": 3698.0, "qsc_code_num_lines": 92.0, "qsc_code_num_chars_line_max": 82.0, "qsc_code_num_chars_line_mean": 40.19565217, "qsc_code_frac_chars_alphabet": 0.89175258, "qsc_code_frac_chars_comments": 0.22011898, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.03389831, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00277296, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.03389831, "qsc_codejava_score_lines_no_logic": 0.47457627, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Flow.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
public class Flow extends Armor.Glyph {
private static ItemSprite.Glowing BLUE = new ItemSprite.Glowing( 0x0000FF );
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
//no proc effect, see armor.speedfactor for effect.
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return BLUE;
}
}
| 1,400 | Flow | java | en | java | code | {"qsc_code_num_words": 191, "qsc_code_num_chars": 1400.0, "qsc_code_mean_word_length": 5.59685864, "qsc_code_frac_words_unique": 0.57591623, "qsc_code_frac_chars_top_2grams": 0.06361085, "qsc_code_frac_chars_top_3grams": 0.14218896, "qsc_code_frac_chars_top_4grams": 0.05332086, "qsc_code_frac_chars_dupe_5grams": 0.16651076, "qsc_code_frac_chars_dupe_6grams": 0.05238541, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01878736, "qsc_code_frac_chars_whitespace": 0.16357143, "qsc_code_size_file_byte": 1400.0, "qsc_code_num_lines": 42.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 33.33333333, "qsc_code_frac_chars_alphabet": 0.8941076, "qsc_code_frac_chars_comments": 0.59428571, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13333333, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.01408451, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.46666667, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Potential.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.EnergyParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor.Glyph;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class Potential extends Glyph {
private static ItemSprite.Glowing WHITE = new ItemSprite.Glowing( 0xFFFFFF, 0.6f );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage) {
int level = Math.max( 0, armor.level() );
// lvl 0 - 16.7%
// lvl 1 - 28.6%
// lvl 2 - 37.5%
if (defender instanceof Hero && Random.Int( level + 6 ) >= 5 ) {
int wands = ((Hero) defender).belongings.charge( 1f );
if (wands > 0) {
defender.sprite.centerEmitter().burst(EnergyParticle.FACTORY, 10);
}
}
return damage;
}
@Override
public Glowing glowing() {
return WHITE;
}
}
| 2,007 | Potential | java | en | java | code | {"qsc_code_num_words": 262, "qsc_code_num_chars": 2007.0, "qsc_code_mean_word_length": 5.73664122, "qsc_code_frac_words_unique": 0.52671756, "qsc_code_frac_chars_top_2grams": 0.0904857, "qsc_code_frac_chars_top_3grams": 0.20226214, "qsc_code_frac_chars_top_4grams": 0.20492349, "qsc_code_frac_chars_dupe_5grams": 0.31270792, "qsc_code_frac_chars_dupe_6grams": 0.19693945, "qsc_code_frac_chars_dupe_7grams": 0.07850965, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02307692, "qsc_code_frac_chars_whitespace": 0.15794718, "qsc_code_size_file_byte": 2007.0, "qsc_code_num_lines": 58.0, "qsc_code_num_chars_line_max": 85.0, "qsc_code_num_chars_line_mean": 34.60344828, "qsc_code_frac_chars_alphabet": 0.86627219, "qsc_code_frac_chars_comments": 0.41305431, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.07407407, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00679117, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.07407407, "qsc_codejava_score_lines_no_logic": 0.48148148, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Obfuscation.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
public class Obfuscation extends Armor.Glyph {
private static ItemSprite.Glowing GREY = new ItemSprite.Glowing( 0x888888 );
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
//no proc effect, see armor.stealthfactor for effect.
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return GREY;
}
}
| 1,409 | Obfuscation | java | en | java | code | {"qsc_code_num_words": 191, "qsc_code_num_chars": 1409.0, "qsc_code_mean_word_length": 5.64397906, "qsc_code_frac_words_unique": 0.57591623, "qsc_code_frac_chars_top_2grams": 0.06307978, "qsc_code_frac_chars_top_3grams": 0.14100186, "qsc_code_frac_chars_top_4grams": 0.0528757, "qsc_code_frac_chars_dupe_5grams": 0.16512059, "qsc_code_frac_chars_dupe_6grams": 0.05194805, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02033898, "qsc_code_frac_chars_whitespace": 0.16252661, "qsc_code_size_file_byte": 1409.0, "qsc_code_num_lines": 42.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 33.54761905, "qsc_code_frac_chars_alphabet": 0.89322034, "qsc_code_frac_chars_comments": 0.59190916, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13333333, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.01391304, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.46666667, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Viscosity.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor.Glyph;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Viscosity extends Glyph {
private static ItemSprite.Glowing PURPLE = new ItemSprite.Glowing( 0x8844CC );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage ) {
//FIXME this glyph should really just proc after DR is accounted for.
//should build in functionality for that, but this works for now
int realDamage = damage - Random.NormalIntRange( armor.DRMin(), armor.DRMax());
if (realDamage <= 0) {
return 0;
}
int level = Math.max( 0, armor.level() );
float percent = (level+1)/(float)(level+6);
int amount = (int)Math.ceil(realDamage * percent);
DeferedDamage deferred = Buff.affect( defender, DeferedDamage.class );
deferred.prolong( amount );
defender.sprite.showStatus( CharSprite.WARNING, Messages.get(this, "deferred", amount) );
return damage - amount;
}
@Override
public Glowing glowing() {
return PURPLE;
}
public static class DeferedDamage extends Buff {
{
type = buffType.NEGATIVE;
}
protected int damage = 0;
private static final String DAMAGE = "damage";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( DAMAGE, damage );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
damage = bundle.getInt( DAMAGE );
}
@Override
public boolean attachTo( Char target ) {
if (super.attachTo( target )) {
postpone( TICK );
return true;
} else {
return false;
}
}
public void prolong( int damage ) {
this.damage += damage;
}
@Override
public int icon() {
return BuffIndicator.DEFERRED;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public boolean act() {
if (target.isAlive()) {
int damageThisTick = Math.max(1, (int)(damage*0.1f));
target.damage( damageThisTick, this );
if (target == Dungeon.hero && !target.isAlive()) {
Dungeon.fail( getClass() );
GLog.n( Messages.get(this, "ondeath") );
Badges.validateDeathFromGlyph();
}
spend( TICK );
damage -= damageThisTick;
if (damage <= 0) {
detach();
}
} else {
detach();
}
return true;
}
@Override
public String desc() {
return Messages.get(this, "desc", damage);
}
}
}
| 4,092 | Viscosity | java | en | java | code | {"qsc_code_num_words": 471, "qsc_code_num_chars": 4092.0, "qsc_code_mean_word_length": 6.17197452, "qsc_code_frac_words_unique": 0.3970276, "qsc_code_frac_chars_top_2grams": 0.04334365, "qsc_code_frac_chars_top_3grams": 0.16993464, "qsc_code_frac_chars_top_4grams": 0.18163055, "qsc_code_frac_chars_dupe_5grams": 0.1998624, "qsc_code_frac_chars_dupe_6grams": 0.10182319, "qsc_code_frac_chars_dupe_7grams": 0.04059168, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00963855, "qsc_code_frac_chars_whitespace": 0.1886608, "qsc_code_size_file_byte": 4092.0, "qsc_code_num_lines": 153.0, "qsc_code_num_chars_line_max": 92.0, "qsc_code_num_chars_line_mean": 26.74509804, "qsc_code_frac_chars_alphabet": 0.86596386, "qsc_code_frac_chars_comments": 0.22336266, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.15463918, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00912524, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00251731, "qsc_code_frac_lines_prompt_comments": 0.00653595, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.10309278, "qsc_codejava_score_lines_no_logic": 0.30927835, "qsc_codejava_frac_words_no_modifier": 0.90909091, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Repulsion.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Repulsion extends Armor.Glyph {
private static ItemSprite.Glowing WHITE = new ItemSprite.Glowing( 0xFFFFFF );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage) {
int level = Math.max( 0, armor.level() );
if (Random.Int( level + 5 ) >= 4){
int oppositeHero = attacker.pos + (attacker.pos - defender.pos);
Ballistica trajectory = new Ballistica(attacker.pos, oppositeHero, Ballistica.MAGIC_BOLT);
WandOfBlastWave.throwChar(attacker, trajectory, 2);
}
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return WHITE;
}
}
| 1,841 | Repulsion | java | en | java | code | {"qsc_code_num_words": 237, "qsc_code_num_chars": 1841.0, "qsc_code_mean_word_length": 5.92827004, "qsc_code_frac_words_unique": 0.53586498, "qsc_code_frac_chars_top_2grams": 0.07259786, "qsc_code_frac_chars_top_3grams": 0.16227758, "qsc_code_frac_chars_top_4grams": 0.15658363, "qsc_code_frac_chars_dupe_5grams": 0.1658363, "qsc_code_frac_chars_dupe_6grams": 0.03985765, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01410256, "qsc_code_frac_chars_whitespace": 0.15263444, "qsc_code_size_file_byte": 1841.0, "qsc_code_num_lines": 52.0, "qsc_code_num_chars_line_max": 94.0, "qsc_code_num_chars_line_mean": 35.40384615, "qsc_code_frac_chars_alphabet": 0.88653846, "qsc_code_frac_chars_comments": 0.42422596, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.08333333, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00754717, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.04166667, "qsc_codejava_score_lines_no_logic": 0.41666667, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00JCIV00/cova | src/generate.zig | //! Functions to generate Help Docs, Tab Completion Scripts, and Argument Templates.
// Standard
const std = @import("std");
const fmt = std.fmt;
const fs = std.fs;
const log = std.log;
const mem = std.mem;
// Cova
const utils = @import("utils.zig");
pub const help_docs = @import("generate/help_docs.zig");
pub const HelpDocsConfig = help_docs.HelpDocsConfig;
pub const createHelpDoc = help_docs.createHelpDoc;
pub const tab_completion = @import("generate/tab_completion.zig");
pub const TabCompletionConfig = tab_completion.TabCompletionConfig;
pub const createTabCompletion = tab_completion.createTabCompletion;
pub const arg_template = @import("generate/arg_template.zig");
pub const ArgTemplateConfig = arg_template.ArgTemplateConfig;
pub const createArgTemplate = arg_template.createArgTemplate;
/// Config for setting up all Meta Docs
pub const MetaDocConfig = struct{
/// Specify which kinds of Meta Docs should be generated.
kinds: []const MetaDocKind = &.{ .all },
/// Help Docs Config
help_docs_config: ?HelpDocsConfig = .{},
/// Tab Completion Config
tab_complete_config: ?TabCompletionConfig = .{},
/// Argument Template Config
arg_template_config: ?ArgTemplateConfig = .{},
/// Command Type Name.
/// This is the name of the Command Type declaration in the main source file.
cmd_type_name: []const u8 = "CommandT",
/// Setup Command Name.
/// This is the name of the comptime Setup Command in the main source file.
setup_cmd_name: []const u8 = "setup_cmd",
/// Name of the program.
/// Note, if this is left null, the provided CommandT's name will be used.
name: ?[]const u8 = null,
/// Description of the program.
/// Note, if this is left null, the provided CommandT's description will be used.
description: ?[]const u8 = null,
/// Version of the program.
version: ?[]const u8 = null,
/// Date of the program version.
ver_date: ?[]const u8 = null,
/// Author of the program.
author: ?[]const u8 = null,
/// Copyright info.
copyright: ?[]const u8 = null,
/// Different Kinds of Meta Documents (Help Docs, Tab Completions, and Arg Templates) available.
pub const MetaDocKind = enum {
/// This is the same as adding All of the MetaDocKinds.
all,
/// Generate Manpages Help Docs.
manpages,
/// Generate Markdown Help Docs.
markdown,
/// Generate a Bash Tab Completion Script.
bash,
/// Generate a Zsh Tab Completion Script.
zsh,
/// Generate a PowerShell Tab Completion Script.
ps1,
/// Generate a JSON Argument Template.
/// This is useful for parsing the main Command using external tools.
json,
/// Generate a KDL Argument Template for use with the [`usage`](https://github.com/jdx/usage) tool.
kdl,
};
};
| 2,891 | generate | zig | en | zig | code | {"qsc_code_num_words": 362, "qsc_code_num_chars": 2891.0, "qsc_code_mean_word_length": 5.29281768, "qsc_code_frac_words_unique": 0.30939227, "qsc_code_frac_chars_top_2grams": 0.04592902, "qsc_code_frac_chars_top_3grams": 0.03444676, "qsc_code_frac_chars_top_4grams": 0.01356994, "qsc_code_frac_chars_dupe_5grams": 0.09707724, "qsc_code_frac_chars_dupe_6grams": 0.07724426, "qsc_code_frac_chars_dupe_7grams": 0.07724426, "qsc_code_frac_chars_dupe_8grams": 0.05427975, "qsc_code_frac_chars_dupe_9grams": 0.05427975, "qsc_code_frac_chars_dupe_10grams": 0.05427975, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00400891, "qsc_code_frac_chars_whitespace": 0.22345209, "qsc_code_size_file_byte": 2891.0, "qsc_code_num_lines": 75.0, "qsc_code_num_chars_line_max": 108.0, "qsc_code_num_chars_line_mean": 38.54666667, "qsc_code_frac_chars_alphabet": 0.84944321, "qsc_code_frac_chars_comments": 0.47180906, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.05128205, "qsc_code_cate_autogen": 1.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.06749672, "qsc_code_frac_chars_long_word_length": 0.04849279, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 1, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfCorrosion;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfCorruption;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfDisintegration;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfLivingEarth;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfRegrowth;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndItem;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
import java.util.ArrayList;
public class MagesStaff extends MeleeWeapon {
private Wand wand;
public static final String AC_IMBUE = "IMBUE";
public static final String AC_ZAP = "ZAP";
private static final float STAFF_SCALE_FACTOR = 0.75f;
{
image = ItemSpriteSheet.MAGES_STAFF;
tier = 1;
defaultAction = AC_ZAP;
usesTargeting = true;
unique = true;
bones = false;
}
public MagesStaff() {
wand = null;
}
@Override
public int max(int lvl) {
return 4*(tier+1) + //8 base damage, down from 10
lvl*(tier+1); //scaling unaffected
}
public MagesStaff(Wand wand){
this();
wand.identify();
wand.cursed = false;
this.wand = wand;
updateWand(false);
wand.curCharges = wand.maxCharges;
name = Messages.get(wand, "staff_name");
}
@Override
public ArrayList<String> actions(Hero hero) {
ArrayList<String> actions = super.actions( hero );
actions.add(AC_IMBUE);
if (wand!= null && wand.curCharges > 0) {
actions.add( AC_ZAP );
}
return actions;
}
@Override
public void activate( Char ch ) {
if(wand != null) wand.charge( ch, STAFF_SCALE_FACTOR );
}
@Override
public void execute(Hero hero, String action) {
super.execute(hero, action);
if (action.equals(AC_IMBUE)) {
curUser = hero;
GameScene.selectItem(itemSelector, WndBag.Mode.WAND, Messages.get(this, "prompt"));
} else if (action.equals(AC_ZAP)){
if (wand == null) {
GameScene.show(new WndItem(null, this, true));
return;
}
if (cursed || hasCurseEnchant()) wand.cursed = true;
else wand.cursed = false;
wand.execute(hero, AC_ZAP);
}
}
@Override
public int proc(Char attacker, Char defender, int damage) {
if (wand != null &&
attacker instanceof Hero && ((Hero)attacker).subClass == HeroSubClass.BATTLEMAGE) {
if (wand.curCharges < wand.maxCharges) wand.partialCharge += 0.33f;
ScrollOfRecharging.charge((Hero)attacker);
wand.onHit(this, attacker, defender, damage);
}
return super.proc(attacker, defender, damage);
}
@Override
public int reachFactor(Char owner) {
int reach = super.reachFactor(owner);
if (owner instanceof Hero
&& wand instanceof WandOfDisintegration
&& ((Hero)owner).subClass == HeroSubClass.BATTLEMAGE){
reach++;
}
return reach;
}
@Override
public boolean collect( Bag container ) {
if (super.collect(container)) {
if (container.owner != null && wand != null) {
wand.charge(container.owner, STAFF_SCALE_FACTOR);
}
return true;
} else {
return false;
}
}
@Override
public void onDetach( ) {
if (wand != null) wand.stopCharging();
}
public Item imbueWand(Wand wand, Char owner){
this.wand = null;
//syncs the level of the two items.
int targetLevel = Math.max(this.level() - (curseInfusionBonus ? 1 : 0), wand.level());
//if the staff's level is being overridden by the wand, preserve 1 upgrade
if (wand.level() >= this.level() && this.level() > (curseInfusionBonus ? 1 : 0)) targetLevel++;
level(targetLevel);
this.wand = wand;
updateWand(false);
wand.curCharges = wand.maxCharges;
if (owner != null) wand.charge(owner);
name = Messages.get(wand, "staff_name");
//This is necessary to reset any particles.
//FIXME this is gross, should implement a better way to fully reset quickslot visuals
int slot = Dungeon.quickslot.getSlot(this);
if (slot != -1){
Dungeon.quickslot.clearSlot(slot);
updateQuickslot();
Dungeon.quickslot.setSlot( slot, this );
updateQuickslot();
}
Badges.validateItemLevelAquired(this);
return this;
}
public void gainCharge( float amt ){
if (wand != null){
wand.gainCharge(amt);
}
}
public Class<?extends Wand> wandClass(){
return wand != null ? wand.getClass() : null;
}
@Override
public Item upgrade(boolean enchant) {
super.upgrade( enchant );
updateWand(true);
return this;
}
@Override
public Item degrade() {
super.degrade();
updateWand(false);
return this;
}
public void updateWand(boolean levelled){
if (wand != null) {
int curCharges = wand.curCharges;
wand.level(level());
//gives the wand one additional max charge
wand.maxCharges = Math.min(wand.maxCharges + 1, 10);
wand.curCharges = Math.min(curCharges + (levelled ? 1 : 0), wand.maxCharges);
updateQuickslot();
}
}
@Override
public String status() {
if (wand == null) return super.status();
else return wand.status();
}
@Override
public String info() {
String info = super.info();
if (wand == null){
//FIXME this is removed because of journal stuff, and is generally unused.
//perhaps reword to fit in journal better
//info += "\n\n" + Messages.get(this, "no_wand");
} else {
info += "\n\n" + Messages.get(this, "has_wand", Messages.get(wand, "name")) + " " + wand.statsDesc();
}
return info;
}
@Override
public Emitter emitter() {
if (wand == null) return null;
Emitter emitter = new Emitter();
emitter.pos(12.5f, 3);
emitter.fillTarget = false;
emitter.pour(StaffParticleFactory, 0.1f);
return emitter;
}
private static final String WAND = "wand";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(WAND, wand);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
wand = (Wand) bundle.get(WAND);
if (wand != null) {
wand.maxCharges = Math.min(wand.maxCharges + 1, 10);
name = Messages.get(wand, "staff_name");
}
}
@Override
public int price() {
return 0;
}
@Override
public Weapon enchant(Enchantment ench) {
if (curseInfusionBonus && (ench == null || !ench.curse())){
curseInfusionBonus = false;
updateWand(false);
}
return super.enchant(ench);
}
private final WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect( final Item item ) {
if (item != null) {
if (!item.isIdentified()) {
GLog.w(Messages.get(MagesStaff.class, "id_first"));
return;
} else if (item.cursed){
GLog.w(Messages.get(MagesStaff.class, "cursed"));
return;
}
if (wand == null){
applyWand((Wand)item);
} else {
final int newLevel =
item.level() >= level() ?
level() > 0 ?
item.level() + 1
: item.level()
: level();
GameScene.show(
new WndOptions("",
Messages.get(MagesStaff.class, "warning", newLevel),
Messages.get(MagesStaff.class, "yes"),
Messages.get(MagesStaff.class, "no")) {
@Override
protected void onSelect(int index) {
if (index == 0) {
applyWand((Wand)item);
}
}
}
);
}
}
}
private void applyWand(Wand wand){
Sample.INSTANCE.play(Assets.SND_BURNING);
curUser.sprite.emitter().burst( ElmoParticle.FACTORY, 12 );
evoke(curUser);
Dungeon.quickslot.clearItem(wand);
wand.detach(curUser.belongings.backpack);
GLog.p( Messages.get(MagesStaff.class, "imbue", wand.name()));
imbueWand( wand, curUser );
updateQuickslot();
}
};
private final Emitter.Factory StaffParticleFactory = new Emitter.Factory() {
@Override
//reimplementing this is needed as instance creation of new staff particles must be within this class.
public void emit( Emitter emitter, int index, float x, float y ) {
StaffParticle c = (StaffParticle)emitter.getFirstAvailable(StaffParticle.class);
if (c == null) {
c = new StaffParticle();
emitter.add(c);
}
c.reset(x, y);
}
@Override
//some particles need light mode, others don't
public boolean lightMode() {
return !((wand instanceof WandOfDisintegration)
|| (wand instanceof WandOfCorruption)
|| (wand instanceof WandOfCorrosion)
|| (wand instanceof WandOfRegrowth)
|| (wand instanceof WandOfLivingEarth));
}
};
//determines particle effects to use based on wand the staff owns.
public class StaffParticle extends PixelParticle{
private float minSize;
private float maxSize;
public float sizeJitter = 0;
public StaffParticle(){
super();
}
public void reset( float x, float y ) {
revive();
speed.set(0);
this.x = x;
this.y = y;
if (wand != null)
wand.staffFx( this );
}
public void setSize( float minSize, float maxSize ){
this.minSize = minSize;
this.maxSize = maxSize;
}
public void setLifespan( float life ){
lifespan = left = life;
}
public void shuffleXY(float amt){
x += Random.Float(-amt, amt);
y += Random.Float(-amt, amt);
}
public void radiateXY(float amt){
float hypot = (float)Math.hypot(speed.x, speed.y);
this.x += speed.x/hypot*amt;
this.y += speed.y/hypot*amt;
}
@Override
public void update() {
super.update();
size(minSize + (left / lifespan)*(maxSize-minSize) + Random.Float(sizeJitter));
}
}
}
| 11,556 | MagesStaff | java | en | java | code | {"qsc_code_num_words": 1354, "qsc_code_num_chars": 11556.0, "qsc_code_mean_word_length": 5.92245199, "qsc_code_frac_words_unique": 0.25701625, "qsc_code_frac_chars_top_2grams": 0.0325477, "qsc_code_frac_chars_top_3grams": 0.11846864, "qsc_code_frac_chars_top_4grams": 0.13168724, "qsc_code_frac_chars_dupe_5grams": 0.19827909, "qsc_code_frac_chars_dupe_6grams": 0.11098641, "qsc_code_frac_chars_dupe_7grams": 0.03367003, "qsc_code_frac_chars_dupe_8grams": 0.03367003, "qsc_code_frac_chars_dupe_9grams": 0.01371742, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00625397, "qsc_code_frac_chars_whitespace": 0.18362755, "qsc_code_size_file_byte": 11556.0, "qsc_code_num_lines": 436.0, "qsc_code_num_chars_line_max": 105.0, "qsc_code_num_chars_line_mean": 26.50458716, "qsc_code_frac_chars_alphabet": 0.84375662, "qsc_code_frac_chars_comments": 0.12867774, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.17682927, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00953421, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.00229358, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.0945122, "qsc_codejava_score_lines_no_logic": 0.24085366, "qsc_codejava_frac_words_no_modifier": 0.90909091, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/WornShortsword.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class WornShortsword extends MeleeWeapon {
{
image = ItemSpriteSheet.WORN_SHORTSWORD;
tier = 1;
bones = false;
}
}
| 1,062 | WornShortsword | java | en | java | code | {"qsc_code_num_words": 147, "qsc_code_num_chars": 1062.0, "qsc_code_mean_word_length": 5.40816327, "qsc_code_frac_words_unique": 0.67346939, "qsc_code_frac_chars_top_2grams": 0.04150943, "qsc_code_frac_chars_top_3grams": 0.0490566, "qsc_code_frac_chars_top_4grams": 0.07169811, "qsc_code_frac_chars_dupe_5grams": 0.10314465, "qsc_code_frac_chars_dupe_6grams": 0.07044025, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02073733, "qsc_code_frac_chars_whitespace": 0.1826742, "qsc_code_size_file_byte": 1062.0, "qsc_code_num_lines": 35.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 30.34285714, "qsc_code_frac_chars_alphabet": 0.89516129, "qsc_code_frac_chars_comments": 0.7354049, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.0, "qsc_codejava_score_lines_no_logic": 0.22222222, "qsc_codejava_frac_words_no_modifier": 0.0, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": null, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/AssassinsBlade.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.utils.Random;
public class AssassinsBlade extends MeleeWeapon {
{
image = ItemSpriteSheet.ASSASSINS_BLADE;
tier = 4;
}
@Override
public int max(int lvl) {
return 4*(tier+1) + //20 base, down from 25
lvl*(tier+1); //scaling unchanged
}
@Override
public int damageRoll(Char owner) {
if (owner instanceof Hero) {
Hero hero = (Hero)owner;
Char enemy = hero.enemy();
if (enemy instanceof Mob && ((Mob) enemy).surprisedBy(hero)) {
//deals 50% toward max to max on surprise, instead of min to max.
int diff = max() - min();
int damage = augment.damageFactor(Random.NormalIntRange(
min() + Math.round(diff*0.50f),
max()));
int exStr = hero.STR() - STRReq();
if (exStr > 0) {
damage += Random.IntRange(0, exStr);
}
return damage;
}
}
return super.damageRoll(owner);
}
} | 1,989 | AssassinsBlade | java | en | java | code | {"qsc_code_num_words": 265, "qsc_code_num_chars": 1989.0, "qsc_code_mean_word_length": 5.35471698, "qsc_code_frac_words_unique": 0.54716981, "qsc_code_frac_chars_top_2grams": 0.05990134, "qsc_code_frac_chars_top_3grams": 0.13389711, "qsc_code_frac_chars_top_4grams": 0.12403101, "qsc_code_frac_chars_dupe_5grams": 0.16349542, "qsc_code_frac_chars_dupe_6grams": 0.03946441, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0197775, "qsc_code_frac_chars_whitespace": 0.18652589, "qsc_code_size_file_byte": 1989.0, "qsc_code_num_lines": 64.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 31.078125, "qsc_code_frac_chars_alphabet": 0.85723115, "qsc_code_frac_chars_comments": 0.44645551, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.05555556, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.05555556, "qsc_codejava_score_lines_no_logic": 0.25, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00JCIV00/cova | examples/cova_demo_meta/tab_completions/_covademo-completion.zsh | #compdef covademo
# This Tab Completion script was generated by the Cova Library.
# Details at https://github.com/00JCIV00/cova
# Zsh Completion Installation Instructions for covademo
# 1. Place this script in a directory specified in your $fpath, or a new one such as
# ~/.zsh/completion/
#
# 2. Ensure the script has executable permissions:
# chmod +x _covademo-completion.zsh
#
# 3. Add the script's directory to your $fpath in your .zshrc if not already included:
# fpath=(~/.zsh/completion $fpath)
#
# 4. Enable and initialize completion in your .zshrc if you haven't already (oh-my-zsh does this automatically):
# autoload -Uz compinit && compinit
#
# 5. Restart your terminal session or source your .zshrc again:
# source ~/.zshrc
# Associative array to hold Commands, Options, and their descriptions with arbitrary depth
typeset -A cmd_args
cmd_args=(
"covademo" "sub-cmd basic nest-1 struct-cmd union-cmd fn-cmd add-user help usage --string --int --float --file --ordinal --cardinal --toggle --bool --verbosity --help --usage"
"covademo_sub-cmd" "help usage --nested_str --help --usage"
"covademo_basic" "help usage --help --usage"
"covademo_nest-1" "nest-2 help usage --help --usage"
"covademo_nest-1_nest-2" "nest-3 help usage --help --usage"
"covademo_nest-1_nest-2_nest-3" "nest-4 help usage --inheritable --help --usage"
"covademo_nest-1_nest-2_nest-3_nest-4" "help usage --help --usage"
"covademo_struct-cmd" "inner-cmd help usage --int --str --str2 --flt --int2 --multi-int --multi-str --rgb-enum --struct-bool --struct-str --struct-int --help --usage"
"covademo_struct-cmd_inner-cmd" "help usage --in-bool --in-float --h-string --help --usage"
"covademo_union-cmd" "help usage --int --str --help --usage"
"covademo_fn-cmd" "help usage --help --usage"
"covademo_add-user" "help usage --fname --lname --age --admin --ref-ids --help --usage"
)
# Generic function for command completions
_covademo_completions() {
local -a completions
# Determine the current command context
local context="covademo"
for word in "${words[@]:1:$CURRENT-1}"; do
if [[ -n $cmd_args[${context}_${word}] ]]; then
context="${context}_${word}"
fi
done
# Generate completions for the current context
completions=(${(s: :)cmd_args[$context]})
if [[ -n $completions ]]; then
_describe -t commands "covademo" completions && return 0
fi
}
_covademo_completions "$@" | 2,489 | _covademo-completion | zsh | en | shell | code | {"qsc_code_num_words": 351, "qsc_code_num_chars": 2489.0, "qsc_code_mean_word_length": 4.76638177, "qsc_code_frac_words_unique": 0.39316239, "qsc_code_frac_chars_top_2grams": 0.12910938, "qsc_code_frac_chars_top_3grams": 0.11177525, "qsc_code_frac_chars_top_4grams": 0.05379558, "qsc_code_frac_chars_dupe_5grams": 0.18768679, "qsc_code_frac_chars_dupe_6grams": 0.15780036, "qsc_code_frac_chars_dupe_7grams": 0.15780036, "qsc_code_frac_chars_dupe_8grams": 0.15780036, "qsc_code_frac_chars_dupe_9grams": 0.15780036, "qsc_code_frac_chars_dupe_10grams": 0.08487747, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01363858, "qsc_code_frac_chars_whitespace": 0.17517075, "qsc_code_size_file_byte": 2489.0, "qsc_code_num_lines": 56.0, "qsc_code_num_chars_line_max": 180.0, "qsc_code_num_chars_line_mean": 44.44642857, "qsc_code_frac_chars_alphabet": 0.80126644, "qsc_code_frac_chars_comments": 0.39132182, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.06896552, "qsc_code_cate_autogen": 1.0, "qsc_code_frac_lines_long_string": 0.06896552, "qsc_code_frac_chars_string_length": 0.64907652, "qsc_code_frac_chars_long_word_length": 0.09234828, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 1, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0} |
00JCIV00/cova | examples/cova_demo_meta/tab_completions/covademo-completion.ps1 | # Requires PowerShell v5.1+
# This Tab Completion script was generated by the Cova Library.
# Details at https://github.com/00JCIV00/cova
# PowerShell Completion Installation Instructions for covademo
# 1. Load the completion script into your current PowerShell session:
# . .\covademo-completion.ps1
#
# 2. Ensure your Execution Policy allows the script to be run. Example:
# Set-ExecutionPolicy RemoteSigned
#
# 3. To ensure this completion script is loaded automatically in future sessions,
# add the above sourcing command to your PowerShell profile:
# Notepad $PROFILE
# Add the line: . C:\path\to\covademo-completion.ps1
#
# 4. Restart your PowerShell session or source your profile again:
# . $PROFILE
function _covademo {
param($wordToComplete, $commandAst)
$suggestions = @(
'sub-cmd',
'basic',
'nest-1',
'struct-cmd',
'union-cmd',
'fn-cmd',
'add-user',
'help',
'usage',
'--string',
'--int',
'--float',
'--file',
'--ordinal',
'--cardinal',
'--toggle',
'--bool',
'--verbosity',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _covademo-sub-cmd {
param($wordToComplete, $commandAst)
$suggestions = @(
'help',
'usage',
'--nested_str',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _covademo-basic {
param($wordToComplete, $commandAst)
$suggestions = @(
'help',
'usage',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _covademo-nest-1 {
param($wordToComplete, $commandAst)
$suggestions = @(
'nest-2',
'help',
'usage',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _covademo-nest-1-nest-2 {
param($wordToComplete, $commandAst)
$suggestions = @(
'nest-3',
'help',
'usage',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _covademo-nest-1-nest-2-nest-3 {
param($wordToComplete, $commandAst)
$suggestions = @(
'nest-4',
'help',
'usage',
'--inheritable',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _covademo-nest-1-nest-2-nest-3-nest-4 {
param($wordToComplete, $commandAst)
$suggestions = @(
'help',
'usage',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _covademo-struct-cmd {
param($wordToComplete, $commandAst)
$suggestions = @(
'inner-cmd',
'help',
'usage',
'--int',
'--str',
'--str2',
'--flt',
'--int2',
'--multi-int',
'--multi-str',
'--rgb-enum',
'--struct-bool',
'--struct-str',
'--struct-int',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _covademo-struct-cmd-inner-cmd {
param($wordToComplete, $commandAst)
$suggestions = @(
'help',
'usage',
'--in-bool',
'--in-float',
'--h-string',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _covademo-union-cmd {
param($wordToComplete, $commandAst)
$suggestions = @(
'help',
'usage',
'--int',
'--str',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _covademo-fn-cmd {
param($wordToComplete, $commandAst)
$suggestions = @(
'help',
'usage',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
function _covademo-add-user {
param($wordToComplete, $commandAst)
$suggestions = @(
'help',
'usage',
'--fname',
'--lname',
'--age',
'--admin',
'--ref-ids',
'--help',
'--usage'
)
return $suggestions | Where-Object { $_ -like "$wordToComplete*" }
}
Register-ArgumentCompleter -CommandName 'covademo.exe' -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPos)
$functionName = "_" + $($commandAst.Extent.Text.replace(' ', '-').replace(".exe", ""))
if ($wordToComplete) {
$functionName = $functionName.replace("-$wordToComplete", "")
}
# Check if the function exists and invoke it
if (Get-Command -Name $functionName -ErrorAction SilentlyContinue) {
& $functionName $wordToComplete $commandAst
} else {
# Fallback logic to show files in the current directory
Get-ChildItem -Path '.' -File | Where-Object Name -like "*$wordToComplete*" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, 'ParameterValue', $_.Name)
}
}
} | 4,734 | covademo-completion | ps1 | en | powershell | code | {"qsc_code_num_words": 460, "qsc_code_num_chars": 4734.0, "qsc_code_mean_word_length": 6.24782609, "qsc_code_frac_words_unique": 0.30869565, "qsc_code_frac_chars_top_2grams": 0.07515658, "qsc_code_frac_chars_top_3grams": 0.13117606, "qsc_code_frac_chars_top_4grams": 0.16701461, "qsc_code_frac_chars_dupe_5grams": 0.50452331, "qsc_code_frac_chars_dupe_6grams": 0.44467641, "qsc_code_frac_chars_dupe_7grams": 0.427627, "qsc_code_frac_chars_dupe_8grams": 0.37230341, "qsc_code_frac_chars_dupe_9grams": 0.35316632, "qsc_code_frac_chars_dupe_10grams": 0.35316632, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00741525, "qsc_code_frac_chars_whitespace": 0.20236586, "qsc_code_size_file_byte": 4734.0, "qsc_code_num_lines": 215.0, "qsc_code_num_chars_line_max": 110.0, "qsc_code_num_chars_line_mean": 22.01860465, "qsc_code_frac_chars_alphabet": 0.75370763, "qsc_code_frac_chars_comments": 0.0, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.45408163, "qsc_code_cate_autogen": 1.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.18289335, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 1, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Scimitar.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class Scimitar extends MeleeWeapon {
{
image = ItemSpriteSheet.SCIMITAR;
tier = 3;
DLY = 0.8f; //1.25x speed
}
@Override
public int max(int lvl) {
return 4*(tier+1) + //16 base, down from 20
lvl*(tier+1); //scaling unchanged
}
}
| 1,189 | Scimitar | java | en | java | code | {"qsc_code_num_words": 170, "qsc_code_num_chars": 1189.0, "qsc_code_mean_word_length": 5.09411765, "qsc_code_frac_words_unique": 0.66470588, "qsc_code_frac_chars_top_2grams": 0.03810624, "qsc_code_frac_chars_top_3grams": 0.04503464, "qsc_code_frac_chars_top_4grams": 0.06581986, "qsc_code_frac_chars_dupe_5grams": 0.09468822, "qsc_code_frac_chars_dupe_6grams": 0.06466513, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.03118503, "qsc_code_frac_chars_whitespace": 0.19091674, "qsc_code_size_file_byte": 1189.0, "qsc_code_num_lines": 40.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 29.725, "qsc_code_frac_chars_alphabet": 0.86902287, "qsc_code_frac_chars_comments": 0.70311186, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.07142857, "qsc_codejava_score_lines_no_logic": 0.21428571, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Flail.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class Flail extends MeleeWeapon {
{
image = ItemSpriteSheet.FLAIL;
tier = 4;
ACC = 0.9f; //0.9x accuracy
//also cannot surprise attack, see Hero.canSurpriseAttack
}
@Override
public int max(int lvl) {
return Math.round(7*(tier+1)) + //35 base, up from 25
lvl*Math.round(1.6f*(tier+1)); //+8 per level, up from +5
}
}
| 1,281 | Flail | java | en | java | code | {"qsc_code_num_words": 187, "qsc_code_num_chars": 1281.0, "qsc_code_mean_word_length": 4.96791444, "qsc_code_frac_words_unique": 0.6684492, "qsc_code_frac_chars_top_2grams": 0.03552207, "qsc_code_frac_chars_top_3grams": 0.04198062, "qsc_code_frac_chars_top_4grams": 0.0613563, "qsc_code_frac_chars_dupe_5grams": 0.08826695, "qsc_code_frac_chars_dupe_6grams": 0.06027987, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.03173077, "qsc_code_frac_chars_whitespace": 0.18813427, "qsc_code_size_file_byte": 1281.0, "qsc_code_num_lines": 40.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 32.025, "qsc_code_frac_chars_alphabet": 0.86153846, "qsc_code_frac_chars_comments": 0.70257611, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.07142857, "qsc_codejava_score_lines_no_logic": 0.21428571, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00JCIV00/cova | examples/cova_demo_meta/tab_completions/covademo-completion.bash | #! /usr/bin/env bash
# This Tab Completion script was generated by the Cova Library.
# Details at https://github.com/00JCIV00/cova
# Bash Completion Installation Instructions for covademo
# 1. Place this script in a directory like /etc/bash_completion.d/ (Linux)
# or /usr/local/etc/bash_completion.d/ (Mac, if using Homebrew and bash-completion)
#
# 2. Ensure the script has executable permissions:
# chmod +x covademo-completion.bash
#
# 3. Source this script from your .bashrc or .bash_profile by adding:
# . /path/to/covademo-completion.bash
#
# 4. Restart your terminal session or source your profile again:
# source ~/.bashrc # or ~/.bash_profile
_covademo_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"sub-cmd")
_covademo_sub-cmd_completions
;;
"basic")
_covademo_basic_completions
;;
"nest-1")
_covademo_nest-1_completions
;;
"struct-cmd")
_covademo_struct-cmd_completions
;;
"union-cmd")
_covademo_union-cmd_completions
;;
"fn-cmd")
_covademo_fn-cmd_completions
;;
"add-user")
_covademo_add-user_completions
;;
"covademo")
COMPREPLY=($(compgen -W "sub-cmd basic nest-1 struct-cmd union-cmd fn-cmd add-user help usage --string --int --float --file --ordinal --cardinal --toggle --bool --verbosity --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_covademo_sub-cmd_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"sub-cmd")
COMPREPLY=($(compgen -W "help usage --nested_str --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_covademo_basic_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"basic")
COMPREPLY=($(compgen -W "help usage --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_covademo_nest-1_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"nest-2")
_covademonest-1_nest-2_completions
;;
"nest-1")
COMPREPLY=($(compgen -W "nest-2 help usage --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_covademo_nest-1_nest-2_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"nest-3")
_covademo_nest-1nest-2_nest-3_completions
;;
"nest-2")
COMPREPLY=($(compgen -W "nest-3 help usage --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_covademo_nest-1_nest-2_nest-3_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"nest-4")
_covademo_nest-1_nest-2nest-3_nest-4_completions
;;
"nest-3")
COMPREPLY=($(compgen -W "nest-4 help usage --inheritable --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_covademo_nest-1_nest-2_nest-3_nest-4_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"nest-4")
COMPREPLY=($(compgen -W "help usage --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_covademo_struct-cmd_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"inner-cmd")
_covademostruct-cmd_inner-cmd_completions
;;
"struct-cmd")
COMPREPLY=($(compgen -W "inner-cmd help usage --int --str --str2 --flt --int2 --multi-int --multi-str --rgb-enum --struct-bool --struct-str --struct-int --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_covademo_struct-cmd_inner-cmd_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"inner-cmd")
COMPREPLY=($(compgen -W "help usage --in-bool --in-float --h-string --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_covademo_union-cmd_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"union-cmd")
COMPREPLY=($(compgen -W "help usage --int --str --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_covademo_fn-cmd_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"fn-cmd")
COMPREPLY=($(compgen -W "help usage --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
_covademo_add-user_completions() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
case "${prev}" in
"add-user")
COMPREPLY=($(compgen -W "help usage --fname --lname --age --admin --ref-ids --help --usage" -- ${cur}))
;;
*)
COMPREPLY=($(compgen -f -- ${cur}))
esac
}
complete -F _covademo_completions covademo | 6,247 | covademo-completion | bash | en | shell | code | {"qsc_code_num_words": 694, "qsc_code_num_chars": 6247.0, "qsc_code_mean_word_length": 4.64409222, "qsc_code_frac_words_unique": 0.16570605, "qsc_code_frac_chars_top_2grams": 0.06701831, "qsc_code_frac_chars_top_3grams": 0.09680422, "qsc_code_frac_chars_top_4grams": 0.13403661, "qsc_code_frac_chars_dupe_5grams": 0.58485883, "qsc_code_frac_chars_dupe_6grams": 0.57679181, "qsc_code_frac_chars_dupe_7grams": 0.55072913, "qsc_code_frac_chars_dupe_8grams": 0.55072913, "qsc_code_frac_chars_dupe_9grams": 0.53955942, "qsc_code_frac_chars_dupe_10grams": 0.51225566, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01224768, "qsc_code_frac_chars_whitespace": 0.29422123, "qsc_code_size_file_byte": 6247.0, "qsc_code_num_lines": 235.0, "qsc_code_num_chars_line_max": 213.0, "qsc_code_num_chars_line_mean": 26.58297872, "qsc_code_frac_chars_alphabet": 0.71875709, "qsc_code_frac_chars_comments": 0.10661117, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.75789474, "qsc_code_cate_autogen": 1.0, "qsc_code_frac_lines_long_string": 0.01052632, "qsc_code_frac_chars_string_length": 0.28341096, "qsc_code_frac_chars_long_word_length": 0.10318882, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 1, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 1, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0} |
00JCIV00/cova | examples/cova_demo_meta/arg_templates/covademo-template.kdl | # This KDL template is formatted to match the `usage` tool as detailed here: https://sr.ht/~jdx/usage/
name "covademo"
bin "covademo"
about "A demo of the Cova command line argument parser."
version "0.10.2"
author "00JCIV00"
flag "-s,--string" help="A string option. (Can be given up to 4 times.)"
flag "-i,--int" help="An integer option. (Can be given up to 10 times.)"
flag "-f,--float" help="An float option. (Can be given up to 10 times.)"
flag "-F,--file" help="A filepath option."
flag "-o,--ordinal" help="An ordinal number option."
flag "-c,--cardinal" help="A cardinal number option."
flag "-t,--toggle" help="A toggle/boolean option."
flag "-b,--bool" help="A toggle/boolean option."
flag "-v,--verbosity" help="Set the CovaDemo verbosity level. (WIP)"
arg "cmd_str" help="A string value for the command."
arg "cmd_bool" help="A boolean value for the command."
arg "cmd_u64" help="A u64 value for the command."
cmd "sub-cmd" help="A demo sub command." {
alias "alias-cmd"
alias "test-alias"
flag "-i," help="A nested integer option."
flag "-s,--nested_str" help="A nested string option."
arg "nested_str_val" help="A nested string value."
arg "nested_float_val" help="A nested float value."
}
cmd "basic" help="The most basic Command." {
alias "basic-cmd"
}
cmd "nest-1" help="Nested Level 1." {
cmd "nest-2" help="Nested Level 2." {
cmd "nest-3" help="Nested Level 3." {
flag "-i,--inheritable" help="Inheritable Option"
cmd "nest-4" help="Nested Level 4."
}
}
}
cmd "struct-cmd" help="A demo sub command made from a struct." {
flag "-i,--int" help="The first Integer Value for the struct-cmd."
flag "-s,--str" help="The 'str' Option."
flag "-S,--str2" help="The 'str2' Option."
flag "-f,--flt" help="The 'flt' Option."
flag "-I,--int2" help="The 'int2' Option."
flag "-m,--multi-int" help="The 'multi-int' Value."
flag "-M,--multi-str" help="The 'multi-str' Value."
flag "-r,--rgb-enum" help="The 'rgb-enum' Option."
flag "-t,--struct-bool" help="The 'struct_bool' Option of type 'toggle'."
flag "-T,--struct-str" help="The 'struct_str' Option of type 'text'."
flag "-R,--struct-int" help="The 'struct_int' Option of type 'i64'."
arg "multi-int-val" help="The 'multi-int-val' Value."
cmd "inner-cmd" help="An inner/nested command for struct-cmd" {
flag "-i,--in-bool" help="The 'in_bool' Option of type 'toggle'."
flag "-I,--in-float" help="The 'in_float' Option of type 'f32'."
flag "-H,--h-string" help="The 'h_string' Option of type 'text'."
}
}
cmd "union-cmd" help="A demo sub command made from a union." {
flag "-i,--int" help="The first Integer Value for the union-cmd."
flag "-s,--str" help="The first String Value for the union-cmd."
arg "union-uint" help="The 'union-uint' Value."
arg "union-str" help="The 'union-str' Value."
}
cmd "fn-cmd" help="A demo sub command made from a function." {
arg "int" help="The first Integer Value for the fn-cmd."
arg "string" help="The first String Value for the fn-cmd."
arg "byte_array" help="A 6-Byte Array for fn-cmd"
}
cmd "add-user" help="A demo sub command for adding a user." {
flag "-f,--fname" help="The 'fname' Option."
flag "-l,--lname" help="The 'lname' Option."
flag "-a,--age" help="The 'age' Option."
flag "-A,--admin" help="The 'admin' Option."
flag "-r,--ref-ids" help="The 'ref-ids' Value."
arg "id" help="The 'id' Value."
}
| 3,527 | covademo-template | kdl | en | unknown | unknown | {} | 0 | {} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Bolas.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class Bolas extends MissileWeapon {
{
image = ItemSpriteSheet.BOLAS;
tier = 3;
baseUses = 5;
}
@Override
public int max(int lvl) {
return 3 * tier + //9 base, down from 15
(tier == 1 ? 2*lvl : tier*lvl); //scaling unchanged
}
@Override
public int proc( Char attacker, Char defender, int damage ) {
Buff.prolong( defender, Cripple.class, Cripple.DURATION );
return super.proc( attacker, defender, damage );
}
}
| 1,600 | Bolas | java | en | java | code | {"qsc_code_num_words": 211, "qsc_code_num_chars": 1600.0, "qsc_code_mean_word_length": 5.57819905, "qsc_code_frac_words_unique": 0.57819905, "qsc_code_frac_chars_top_2grams": 0.0722175, "qsc_code_frac_chars_top_3grams": 0.16142736, "qsc_code_frac_chars_top_4grams": 0.14953271, "qsc_code_frac_chars_dupe_5grams": 0.20560748, "qsc_code_frac_chars_dupe_6grams": 0.14103653, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01911315, "qsc_code_frac_chars_whitespace": 0.1825, "qsc_code_size_file_byte": 1600.0, "qsc_code_num_lines": 49.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 32.65306122, "qsc_code_frac_chars_alphabet": 0.88073394, "qsc_code_frac_chars_comments": 0.51375, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.09090909, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.09090909, "qsc_codejava_score_lines_no_logic": 0.31818182, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Tomahawk.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class Tomahawk extends MissileWeapon {
{
image = ItemSpriteSheet.TOMAHAWK;
tier = 4;
baseUses = 5;
}
@Override
public int min(int lvl) {
return Math.round(1.5f * tier) + //6 base, down from 8
2 * lvl; //scaling unchanged
}
@Override
public int max(int lvl) {
return Math.round(3.75f * tier) + //15 base, down from 20
(tier)*lvl; //scaling unchanged
}
@Override
public int proc( Char attacker, Char defender, int damage ) {
Buff.affect( defender, Bleeding.class ).set( Math.round(damage*0.6f) );
return super.proc( attacker, defender, damage );
}
}
| 1,763 | Tomahawk | java | en | java | code | {"qsc_code_num_words": 235, "qsc_code_num_chars": 1763.0, "qsc_code_mean_word_length": 5.42978723, "qsc_code_frac_words_unique": 0.56170213, "qsc_code_frac_chars_top_2grams": 0.06661442, "qsc_code_frac_chars_top_3grams": 0.14890282, "qsc_code_frac_chars_top_4grams": 0.13793103, "qsc_code_frac_chars_dupe_5grams": 0.27899687, "qsc_code_frac_chars_dupe_6grams": 0.18652038, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02307692, "qsc_code_frac_chars_whitespace": 0.18888259, "qsc_code_size_file_byte": 1763.0, "qsc_code_num_lines": 54.0, "qsc_code_num_chars_line_max": 74.0, "qsc_code_num_chars_line_mean": 32.64814815, "qsc_code_frac_chars_alphabet": 0.86923077, "qsc_code_frac_chars_comments": 0.48950652, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.11111111, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.11111111, "qsc_codejava_score_lines_no_logic": 0.2962963, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/ThrowingClub.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class ThrowingClub extends MissileWeapon {
{
image = ItemSpriteSheet.THROWING_CLUB;
tier = 2;
baseUses = 15;
sticky = false;
}
@Override
public int max(int lvl) {
return 4 * tier + //8 base, down from 10
(tier) * lvl; //scaling unchanged
}
}
| 1,236 | ThrowingClub | java | en | java | code | {"qsc_code_num_words": 167, "qsc_code_num_chars": 1236.0, "qsc_code_mean_word_length": 5.28143713, "qsc_code_frac_words_unique": 0.68263473, "qsc_code_frac_chars_top_2grams": 0.03741497, "qsc_code_frac_chars_top_3grams": 0.04421769, "qsc_code_frac_chars_top_4grams": 0.06462585, "qsc_code_frac_chars_dupe_5grams": 0.09297052, "qsc_code_frac_chars_dupe_6grams": 0.06349206, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02466598, "qsc_code_frac_chars_whitespace": 0.21278317, "qsc_code_size_file_byte": 1236.0, "qsc_code_num_lines": 41.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 30.14634146, "qsc_code_frac_chars_alphabet": 0.88180884, "qsc_code_frac_chars_comments": 0.66423948, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.2, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Trident.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class Trident extends MissileWeapon {
{
image = ItemSpriteSheet.TRIDENT;
tier = 5;
}
}
| 1,037 | Trident | java | en | java | code | {"qsc_code_num_words": 144, "qsc_code_num_chars": 1037.0, "qsc_code_mean_word_length": 5.38888889, "qsc_code_frac_words_unique": 0.65972222, "qsc_code_frac_chars_top_2grams": 0.04252577, "qsc_code_frac_chars_top_3grams": 0.05025773, "qsc_code_frac_chars_top_4grams": 0.07345361, "qsc_code_frac_chars_dupe_5grams": 0.1056701, "qsc_code_frac_chars_dupe_6grams": 0.07216495, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0212766, "qsc_code_frac_chars_whitespace": 0.18418515, "qsc_code_size_file_byte": 1037.0, "qsc_code_num_lines": 34.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 30.5, "qsc_code_frac_chars_alphabet": 0.89598109, "qsc_code_frac_chars_comments": 0.75313404, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.0, "qsc_codejava_score_lines_no_logic": 0.25, "qsc_codejava_frac_words_no_modifier": 0.0, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": null, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/FishingSpear.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class FishingSpear extends MissileWeapon {
{
image = ItemSpriteSheet.FISHING_SPEAR;
tier = 2;
}
@Override
public int proc(Char attacker, Char defender, int damage) {
if (defender instanceof Piranha){
damage = Math.max(damage, defender.HP/2);
}
return super.proc(attacker, defender, damage);
}
}
| 1,387 | FishingSpear | java | en | java | code | {"qsc_code_num_words": 185, "qsc_code_num_chars": 1387.0, "qsc_code_mean_word_length": 5.67027027, "qsc_code_frac_words_unique": 0.61081081, "qsc_code_frac_chars_top_2grams": 0.06482364, "qsc_code_frac_chars_top_3grams": 0.1448999, "qsc_code_frac_chars_top_4grams": 0.05433746, "qsc_code_frac_chars_dupe_5grams": 0.17349857, "qsc_code_frac_chars_dupe_6grams": 0.05338418, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01643599, "qsc_code_frac_chars_whitespace": 0.1665465, "qsc_code_size_file_byte": 1387.0, "qsc_code_num_lines": 43.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 32.25581395, "qsc_code_frac_chars_alphabet": 0.89100346, "qsc_code_frac_chars_comments": 0.5630858, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.05882353, "qsc_codejava_score_lines_no_logic": 0.29411765, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/ThrowingSpear.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class ThrowingSpear extends MissileWeapon {
{
image = ItemSpriteSheet.THROWING_SPEAR;
tier = 3;
}
}
| 1,050 | ThrowingSpear | java | en | java | code | {"qsc_code_num_words": 145, "qsc_code_num_chars": 1050.0, "qsc_code_mean_word_length": 5.43448276, "qsc_code_frac_words_unique": 0.66206897, "qsc_code_frac_chars_top_2grams": 0.04187817, "qsc_code_frac_chars_top_3grams": 0.04949239, "qsc_code_frac_chars_top_4grams": 0.07233503, "qsc_code_frac_chars_dupe_5grams": 0.10406091, "qsc_code_frac_chars_dupe_6grams": 0.07106599, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0209546, "qsc_code_frac_chars_whitespace": 0.18190476, "qsc_code_size_file_byte": 1050.0, "qsc_code_num_lines": 34.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 30.88235294, "qsc_code_frac_chars_alphabet": 0.89639115, "qsc_code_frac_chars_comments": 0.74380952, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.0, "qsc_codejava_score_lines_no_logic": 0.25, "qsc_codejava_frac_words_no_modifier": 0.0, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": null, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/HeavyBoomerang.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.sprites.MissileSprite;
import com.watabou.noosa.tweeners.AlphaTweener;
import com.watabou.utils.Bundle;
import com.watabou.utils.Callback;
public class HeavyBoomerang extends MissileWeapon {
{
image = ItemSpriteSheet.BOOMERANG;
tier = 4;
sticky = false;
}
@Override
public int max(int lvl) {
return 4 * tier + //16 base, down from 20
(tier) * lvl; //scaling unchanged
}
@Override
protected void rangedHit(Char enemy, int cell) {
decrementDurability();
if (durability > 0){
Buff.append(Dungeon.hero, CircleBack.class).setup(this, cell, Dungeon.hero.pos, Dungeon.depth);
}
}
@Override
protected void rangedMiss(int cell) {
parent = null;
Buff.append(Dungeon.hero, CircleBack.class).setup(this, cell, Dungeon.hero.pos, Dungeon.depth);
}
public static class CircleBack extends Buff {
private MissileWeapon boomerang;
private int thrownPos;
private int returnPos;
private int returnDepth;
private int left;
public void setup( MissileWeapon boomerang, int thrownPos, int returnPos, int returnDepth){
this.boomerang = boomerang;
this.thrownPos = thrownPos;
this.returnPos = returnPos;
this.returnDepth = returnDepth;
left = 3;
}
public int returnPos(){
return returnPos;
}
public MissileWeapon cancel(){
detach();
return boomerang;
}
@Override
public boolean act() {
if (returnDepth == Dungeon.depth){
left--;
if (left <= 0){
final Char returnTarget = Actor.findChar(returnPos);
final Char target = this.target;
MissileSprite visual = ((MissileSprite) Dungeon.hero.sprite.parent.recycle(MissileSprite.class));
visual.reset( thrownPos,
returnPos,
boomerang,
new Callback() {
@Override
public void call() {
if (returnTarget == target){
if (target instanceof Hero && boomerang.doPickUp((Hero) target)) {
//grabbing the boomerang takes no time
((Hero) target).spend(-TIME_TO_PICK_UP);
} else {
Dungeon.level.drop(boomerang, returnPos).sprite.drop();
}
} else if (returnTarget != null){
if (((Hero)target).shoot( returnTarget, boomerang )) {
boomerang.decrementDurability();
}
if (boomerang.durability > 0) {
Dungeon.level.drop(boomerang, returnPos).sprite.drop();
}
} else {
Dungeon.level.drop(boomerang, returnPos).sprite.drop();
}
CircleBack.this.next();
}
});
visual.alpha(0f);
float duration = Dungeon.level.trueDistance(thrownPos, returnPos) / 20f;
target.sprite.parent.add(new AlphaTweener(visual, 1f, duration));
detach();
return false;
}
}
spend( TICK );
return true;
}
private static final String BOOMERANG = "boomerang";
private static final String THROWN_POS = "thrown_pos";
private static final String RETURN_POS = "return_pos";
private static final String RETURN_DEPTH = "return_depth";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(BOOMERANG, boomerang);
bundle.put(THROWN_POS, thrownPos);
bundle.put(RETURN_POS, returnPos);
bundle.put(RETURN_DEPTH, returnDepth);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
boomerang = (MissileWeapon) bundle.get(BOOMERANG);
thrownPos = bundle.getInt(THROWN_POS);
returnPos = bundle.getInt(RETURN_POS);
returnDepth = bundle.getInt(RETURN_DEPTH);
}
}
}
| 4,965 | HeavyBoomerang | java | en | java | code | {"qsc_code_num_words": 546, "qsc_code_num_chars": 4965.0, "qsc_code_mean_word_length": 6.17216117, "qsc_code_frac_words_unique": 0.35347985, "qsc_code_frac_chars_top_2grams": 0.02670623, "qsc_code_frac_chars_top_3grams": 0.09020772, "qsc_code_frac_chars_top_4grams": 0.09139466, "qsc_code_frac_chars_dupe_5grams": 0.22077151, "qsc_code_frac_chars_dupe_6grams": 0.12344214, "qsc_code_frac_chars_dupe_7grams": 0.08724036, "qsc_code_frac_chars_dupe_8grams": 0.08724036, "qsc_code_frac_chars_dupe_9grams": 0.04451039, "qsc_code_frac_chars_dupe_10grams": 0.04451039, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00801034, "qsc_code_frac_chars_whitespace": 0.22054381, "qsc_code_size_file_byte": 4965.0, "qsc_code_num_lines": 161.0, "qsc_code_num_chars_line_max": 103.0, "qsc_code_num_chars_line_mean": 30.83850932, "qsc_code_frac_chars_alphabet": 0.8627907, "qsc_code_frac_chars_comments": 0.17321249, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13445378, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00998782, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.09243697, "qsc_codejava_score_lines_no_logic": 0.2605042, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Javelin.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class Javelin extends MissileWeapon {
{
image = ItemSpriteSheet.JAVELIN;
tier = 4;
}
}
| 1,035 | Javelin | java | en | java | code | {"qsc_code_num_words": 144, "qsc_code_num_chars": 1035.0, "qsc_code_mean_word_length": 5.38888889, "qsc_code_frac_words_unique": 0.65972222, "qsc_code_frac_chars_top_2grams": 0.04252577, "qsc_code_frac_chars_top_3grams": 0.05025773, "qsc_code_frac_chars_top_4grams": 0.07345361, "qsc_code_frac_chars_dupe_5grams": 0.1056701, "qsc_code_frac_chars_dupe_6grams": 0.07216495, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0212766, "qsc_code_frac_chars_whitespace": 0.1826087, "qsc_code_size_file_byte": 1035.0, "qsc_code_num_lines": 33.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 31.36363636, "qsc_code_frac_chars_alphabet": 0.89598109, "qsc_code_frac_chars_comments": 0.75458937, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.0, "qsc_codejava_score_lines_no_logic": 0.25, "qsc_codejava_frac_words_no_modifier": 0.0, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": null, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Fragile.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Bundle;
public class Fragile extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
private int hits = 0;
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
//degrades from 100% to 25% damage over 150 hits
damage *= (1f - hits*0.005f);
if (hits < 150) hits++;
return damage;
}
@Override
public boolean curse() {
return true;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
private static final String HITS = "hits";
@Override
public void restoreFromBundle( Bundle bundle ) {
hits = bundle.getInt(HITS);
}
@Override
public void storeInBundle( Bundle bundle ) {
bundle.put(HITS, hits);
}
}
| 1,813 | Fragile | java | en | java | code | {"qsc_code_num_words": 242, "qsc_code_num_chars": 1813.0, "qsc_code_mean_word_length": 5.57438017, "qsc_code_frac_words_unique": 0.54132231, "qsc_code_frac_chars_top_2grams": 0.05189029, "qsc_code_frac_chars_top_3grams": 0.11267606, "qsc_code_frac_chars_top_4grams": 0.04225352, "qsc_code_frac_chars_dupe_5grams": 0.13343217, "qsc_code_frac_chars_dupe_6grams": 0.04151223, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02733333, "qsc_code_frac_chars_whitespace": 0.17264203, "qsc_code_size_file_byte": 1813.0, "qsc_code_num_lines": 63.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 28.77777778, "qsc_code_frac_chars_alphabet": 0.872, "qsc_code_frac_chars_comments": 0.45725317, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.15625, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00406504, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00813008, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.125, "qsc_codejava_score_lines_no_logic": 0.375, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Exhausting.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Weakness;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Exhausting extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc(Weapon weapon, Char attacker, Char defender, int damage ) {
if (attacker == Dungeon.hero && Random.Int(15) == 0) {
Buff.affect(attacker, Weakness.class, Random.NormalIntRange(5, 20));
}
return damage;
}
@Override
public boolean curse() {
return true;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
}
| 1,785 | Exhausting | java | en | java | code | {"qsc_code_num_words": 230, "qsc_code_num_chars": 1785.0, "qsc_code_mean_word_length": 5.96521739, "qsc_code_frac_words_unique": 0.53478261, "qsc_code_frac_chars_top_2grams": 0.08673469, "qsc_code_frac_chars_top_3grams": 0.19387755, "qsc_code_frac_chars_top_4grams": 0.19241983, "qsc_code_frac_chars_dupe_5grams": 0.24781341, "qsc_code_frac_chars_dupe_6grams": 0.12099125, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01973684, "qsc_code_frac_chars_whitespace": 0.14845938, "qsc_code_size_file_byte": 1785.0, "qsc_code_num_lines": 54.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 33.05555556, "qsc_code_frac_chars_alphabet": 0.88289474, "qsc_code_frac_chars_comments": 0.43753501, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.11538462, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00796813, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.07692308, "qsc_codejava_score_lines_no_logic": 0.5, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Wayward.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
public class Wayward extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
//no proc effect, see weapon.accuracyFactor for effect
return damage;
}
@Override
public boolean curse() {
return true;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
}
| 1,478 | Wayward | java | en | java | code | {"qsc_code_num_words": 197, "qsc_code_num_chars": 1478.0, "qsc_code_mean_word_length": 5.71573604, "qsc_code_frac_words_unique": 0.57360406, "qsc_code_frac_chars_top_2grams": 0.06039076, "qsc_code_frac_chars_top_3grams": 0.13499112, "qsc_code_frac_chars_top_4grams": 0.05062167, "qsc_code_frac_chars_dupe_5grams": 0.1598579, "qsc_code_frac_chars_dupe_6grams": 0.04973357, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01946472, "qsc_code_frac_chars_whitespace": 0.16576455, "qsc_code_size_file_byte": 1478.0, "qsc_code_num_lines": 47.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 31.44680851, "qsc_code_frac_chars_alphabet": 0.89375507, "qsc_code_frac_chars_comments": 0.56495264, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.15789474, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.01244168, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.10526316, "qsc_codejava_score_lines_no_logic": 0.47368421, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Polarized.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2018 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Polarized extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
if (Random.Int(2) == 0){
return Math.round(1.5f*damage);
} else {
return 0;
}
}
@Override
public boolean curse() {
return true;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
}
| 1,538 | Polarized | java | en | java | code | {"qsc_code_num_words": 206, "qsc_code_num_chars": 1538.0, "qsc_code_mean_word_length": 5.56796117, "qsc_code_frac_words_unique": 0.58252427, "qsc_code_frac_chars_top_2grams": 0.05928509, "qsc_code_frac_chars_top_3grams": 0.13251962, "qsc_code_frac_chars_top_4grams": 0.04969486, "qsc_code_frac_chars_dupe_5grams": 0.15693112, "qsc_code_frac_chars_dupe_6grams": 0.04882302, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02281668, "qsc_code_frac_chars_whitespace": 0.17360208, "qsc_code_size_file_byte": 1538.0, "qsc_code_num_lines": 53.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 29.01886792, "qsc_code_frac_chars_alphabet": 0.87962234, "qsc_code_frac_chars_comments": 0.50715215, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.125, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.01055409, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.08333333, "qsc_codejava_score_lines_no_logic": 0.41666667, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Displacing.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Displacing extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc(Weapon weapon, Char attacker, Char defender, int damage ) {
if (Random.Int(12) == 0 && !defender.properties().contains(Char.Property.IMMOVABLE)){
int count = 10;
int newPos;
do {
newPos = Dungeon.level.randomRespawnCell();
if (count-- <= 0) {
break;
}
} while (newPos == -1);
if (newPos != -1 && !Dungeon.bossLevel()) {
if (Dungeon.level.heroFOV[defender.pos]) {
CellEmitter.get( defender.pos ).start( Speck.factory( Speck.LIGHT ), 0.2f, 3 );
}
defender.pos = newPos;
if (defender instanceof Mob && ((Mob) defender).state == ((Mob) defender).HUNTING){
((Mob) defender).state = ((Mob) defender).WANDERING;
}
defender.sprite.place( defender.pos );
defender.sprite.visible = Dungeon.level.heroFOV[defender.pos];
return 0;
}
}
return damage;
}
@Override
public boolean curse() {
return true;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
}
| 2,461 | Displacing | java | en | java | code | {"qsc_code_num_words": 303, "qsc_code_num_chars": 2461.0, "qsc_code_mean_word_length": 5.91089109, "qsc_code_frac_words_unique": 0.48844884, "qsc_code_frac_chars_top_2grams": 0.07593523, "qsc_code_frac_chars_top_3grams": 0.16973758, "qsc_code_frac_chars_top_4grams": 0.17197097, "qsc_code_frac_chars_dupe_5grams": 0.27694026, "qsc_code_frac_chars_dupe_6grams": 0.03126745, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01756098, "qsc_code_frac_chars_whitespace": 0.16700528, "qsc_code_size_file_byte": 2461.0, "qsc_code_num_lines": 80.0, "qsc_code_num_chars_line_max": 88.0, "qsc_code_num_chars_line_mean": 30.7625, "qsc_code_frac_chars_alphabet": 0.85609756, "qsc_code_frac_chars_comments": 0.31735067, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.06521739, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0047619, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.04347826, "qsc_codejava_score_lines_no_logic": 0.34782609, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Sacrificial.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Sacrificial extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc(Weapon weapon, Char attacker, Char defender, int damage ) {
if (Random.Int(12) == 0){
Buff.affect(attacker, Bleeding.class).set(Math.max(1, attacker.HP/6));
}
return damage;
}
@Override
public boolean curse() {
return true;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
}
| 1,703 | Sacrificial | java | en | java | code | {"qsc_code_num_words": 225, "qsc_code_num_chars": 1703.0, "qsc_code_mean_word_length": 5.78666667, "qsc_code_frac_words_unique": 0.55555556, "qsc_code_frac_chars_top_2grams": 0.07834101, "qsc_code_frac_chars_top_3grams": 0.17511521, "qsc_code_frac_chars_top_4grams": 0.16897081, "qsc_code_frac_chars_dupe_5grams": 0.26113671, "qsc_code_frac_chars_dupe_6grams": 0.12749616, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0200692, "qsc_code_frac_chars_whitespace": 0.15149736, "qsc_code_size_file_byte": 1703.0, "qsc_code_num_lines": 54.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 31.53703704, "qsc_code_frac_chars_alphabet": 0.88096886, "qsc_code_frac_chars_comments": 0.45860247, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.12, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00867679, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.08, "qsc_codejava_score_lines_no_logic": 0.48, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/AdrenalineDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Adrenaline;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class AdrenalineDart extends TippedDart {
{
image = ItemSpriteSheet.ADRENALINE_DART;
}
@Override
public int proc(Char attacker, Char defender, int damage) {
Buff.prolong( defender, Adrenaline.class, Adrenaline.DURATION);
if (attacker.alignment == defender.alignment){
return 0;
}
return super.proc(attacker, defender, damage);
}
}
| 1,505 | AdrenalineDart | java | en | java | code | {"qsc_code_num_words": 194, "qsc_code_num_chars": 1505.0, "qsc_code_mean_word_length": 5.93298969, "qsc_code_frac_words_unique": 0.57731959, "qsc_code_frac_chars_top_2grams": 0.07384883, "qsc_code_frac_chars_top_3grams": 0.16507385, "qsc_code_frac_chars_top_4grams": 0.15291051, "qsc_code_frac_chars_dupe_5grams": 0.21025195, "qsc_code_frac_chars_dupe_6grams": 0.14422242, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01419558, "qsc_code_frac_chars_whitespace": 0.15747508, "qsc_code_size_file_byte": 1505.0, "qsc_code_num_lines": 46.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 32.7173913, "qsc_code_frac_chars_alphabet": 0.89353312, "qsc_code_frac_chars_comments": 0.51827243, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.05555556, "qsc_codejava_score_lines_no_logic": 0.38888889, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/HolyDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bless;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class HolyDart extends TippedDart {
{
image = ItemSpriteSheet.HOLY_DART;
}
@Override
public int proc(Char attacker, Char defender, int damage) {
Buff.affect(defender, Bless.class, 20f);
if (attacker.alignment == defender.alignment){
return 0;
}
return super.proc(attacker, defender, damage);
}
}
| 1,465 | HolyDart | java | en | java | code | {"qsc_code_num_words": 193, "qsc_code_num_chars": 1465.0, "qsc_code_mean_word_length": 5.76683938, "qsc_code_frac_words_unique": 0.58549223, "qsc_code_frac_chars_top_2grams": 0.07637017, "qsc_code_frac_chars_top_3grams": 0.17070979, "qsc_code_frac_chars_top_4grams": 0.15813118, "qsc_code_frac_chars_dupe_5grams": 0.21743037, "qsc_code_frac_chars_dupe_6grams": 0.14914645, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01627339, "qsc_code_frac_chars_whitespace": 0.16109215, "qsc_code_size_file_byte": 1465.0, "qsc_code_num_lines": 46.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 31.84782609, "qsc_code_frac_chars_alphabet": 0.88934093, "qsc_code_frac_chars_comments": 0.5331058, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.05555556, "qsc_codejava_score_lines_no_logic": 0.38888889, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Gauntlet.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class Gauntlet extends MeleeWeapon {
{
image = ItemSpriteSheet.GAUNTLETS;
tier = 5;
DLY = 0.5f; //2x speed
}
@Override
public int max(int lvl) {
return Math.round(2.5f*(tier+1)) + //15 base, down from 30
lvl*Math.round(0.5f*(tier+1)); //+3 per level, down from +6
}
@Override
public int defenseFactor( Char owner ) {
return 4; //4 extra defence
}
}
| 1,381 | Gauntlet | java | en | java | code | {"qsc_code_num_words": 197, "qsc_code_num_chars": 1381.0, "qsc_code_mean_word_length": 5.09137056, "qsc_code_frac_words_unique": 0.63451777, "qsc_code_frac_chars_top_2grams": 0.0329013, "qsc_code_frac_chars_top_3grams": 0.03888335, "qsc_code_frac_chars_top_4grams": 0.05682951, "qsc_code_frac_chars_dupe_5grams": 0.08175474, "qsc_code_frac_chars_dupe_6grams": 0.0558325, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.03116652, "qsc_code_frac_chars_whitespace": 0.18682114, "qsc_code_size_file_byte": 1381.0, "qsc_code_num_lines": 46.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 30.02173913, "qsc_code_frac_chars_alphabet": 0.86197685, "qsc_code_frac_chars_comments": 0.62201303, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.10526316, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.10526316, "qsc_codejava_score_lines_no_logic": 0.31578947, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Elastic.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2018 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Elastic extends Weapon.Enchantment {
private static ItemSprite.Glowing PINK = new ItemSprite.Glowing( 0xFF00FF );
@Override
public int proc(Weapon weapon, Char attacker, Char defender, int damage ) {
// lvl 0 - 20%
// lvl 1 - 33%
// lvl 2 - 43%
int level = Math.max( 0, weapon.level() );
if (Random.Int( level + 5 ) >= 4) {
//trace a ballistica to our target (which will also extend past them
Ballistica trajectory = new Ballistica(attacker.pos, defender.pos, Ballistica.STOP_TARGET);
//trim it to just be the part that goes past them
trajectory = new Ballistica(trajectory.collisionPos, trajectory.path.get(trajectory.path.size()-1), Ballistica.PROJECTILE);
//knock them back along that ballistica
WandOfBlastWave.throwChar(defender, trajectory, 2);
}
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return PINK;
}
}
| 2,140 | Elastic | java | en | java | code | {"qsc_code_num_words": 282, "qsc_code_num_chars": 2140.0, "qsc_code_mean_word_length": 5.72340426, "qsc_code_frac_words_unique": 0.53191489, "qsc_code_frac_chars_top_2grams": 0.06319703, "qsc_code_frac_chars_top_3grams": 0.14126394, "qsc_code_frac_chars_top_4grams": 0.13630731, "qsc_code_frac_chars_dupe_5grams": 0.14560099, "qsc_code_frac_chars_dupe_6grams": 0.03469641, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01892042, "qsc_code_frac_chars_whitespace": 0.16028037, "qsc_code_size_file_byte": 2140.0, "qsc_code_num_lines": 58.0, "qsc_code_num_chars_line_max": 127.0, "qsc_code_num_chars_line_mean": 36.89655172, "qsc_code_frac_chars_alphabet": 0.87924318, "qsc_code_frac_chars_comments": 0.45747664, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.08333333, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00689061, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.04166667, "qsc_codejava_score_lines_no_logic": 0.41666667, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00JCIV00/cova | src/generate/arg_template.zig | //! Generate Argument Templates that can be easily parsed in external programs.
// Standard
const std = @import("std");
const fmt = std.fmt;
const fs = std.fs;
const json = std.json;
const log = std.log;
const mem = std.mem;
// Cova
const utils = @import("../utils.zig");
/// The Command Template Type, built from a Command Type.
pub fn CommandTemplate(CommandT: type) type {
return struct {
const CmdT: type = CommandT;
const OptTemplateT: type = OptionTemplate(CommandT.OptionT);
const ValTemplateT: type = ValueTemplate(CommandT.ValueT);
/// Command Name
name: []const u8,
/// Command Description
description: []const u8,
/// Command Aliases
aliases: ?[]const []const u8,
/// Command Group
group: ?[]const u8,
/// Command Examples
examples: ?[]const []const u8,
/// Sub-Commands
sub_cmds: ?[]const @This() = null,
/// Options
opts: ?[]const OptionTemplate(CommandT.OptionT) = null,
/// Values
vals: ?[]const ValueTemplate(CommandT.ValueT) = null,
/// Create a Template from a Command (`cmd`) using the provided Argument Template Config (`at_config`).
pub fn from(comptime cmd: CommandT, comptime at_config: ArgTemplateConfig) @This() {
return .{
.name = cmd.name,
.description = cmd.description,
.aliases = cmd.alias_names,
.group = cmd.cmd_group,
.examples = cmd.examples,
.sub_cmds = comptime subCmds: {
if (!at_config.include_cmds) break :subCmds null;
const sub_cmds = cmd.sub_cmds orelse break :subCmds null;
var cmd_tmplts: [sub_cmds.len]@This() = undefined;
for (sub_cmds, cmd_tmplts[0..]) |sub_cmd, *tmplt| tmplt.* = from(sub_cmd, at_config);
const cmd_tmplts_out = cmd_tmplts;
break :subCmds cmd_tmplts_out[0..];
},
.opts = comptime setOpts: {
if (!at_config.include_opts) break :setOpts null;
const opts = cmd.opts orelse break :setOpts null;
var opt_tmplts: [opts.len]OptTemplateT = undefined;
for (opts, opt_tmplts[0..]) |opt, *tmplt| tmplt.* = OptTemplateT.from(opt);
const opt_tmplts_out = opt_tmplts;
break :setOpts opt_tmplts_out[0..];
},
.vals = comptime setvals: {
if (!at_config.include_vals) break :setvals null;
const vals = cmd.vals orelse break :setvals null;
var val_tmplts: [vals.len]ValTemplateT = undefined;
for (vals, val_tmplts[0..]) |val, *tmplt| tmplt.* = ValTemplateT.from(val);
const val_tmplts_out = val_tmplts;
break :setvals val_tmplts_out[0..];
},
};
}
};
}
/// The Option Template Type, built from an Option Type.
pub fn OptionTemplate(OptionT: type) type {
return struct {
const OptT: type = OptionT;
/// Option Name
name: []const u8,
/// Option Long Name
long_name: ?[]const u8,
/// Option Short Name
short_name: ?u8,
/// Option Description
description: []const u8,
/// Option Aliases
aliases: ?[]const []const u8,
/// Option Group
group: ?[]const u8,
/// Value Type Name
type_name: []const u8,
/// Value Type Alias
type_alias: ?[]const u8 = null,
/// Value Set Behavior
set_behavior: []const u8,
/// Value Max Entries
max_entries: u8,
/// Create a Template from an Option.
pub fn from(comptime opt: OptionT) @This() {
return .{
.name = opt.name,
.long_name = opt.long_name,
.short_name = opt.short_name,
.description = opt.description,
.aliases = opt.alias_long_names,
.group = opt.opt_group,
.type_name = opt.val.childType(),
.type_alias = if (!mem.eql(u8, opt.val.childTypeName(), opt.val.childType())) opt.val.childTypeName() else null,
.set_behavior = @tagName(opt.val.setBehavior()),
.max_entries = opt.val.maxEntries(),
};
}
};
}
/// The Value Template Type, built from a Value Type.
pub fn ValueTemplate(ValueT: type) type {
return struct {
const ValT: type = ValueT;
/// Value Name
name: []const u8,
/// Value Description
description: []const u8,
/// Value Group
group: ?[]const u8,
/// Value Type Name
type_name: []const u8,
/// Value Type Alias
type_alias: ?[]const u8 = null,
/// Value Set Behavior
set_behavior: []const u8,
/// Value Max Arguments
max_entries: u8,
/// Create a Template from a Value.
pub fn from(comptime val: ValueT) @This() {
return .{
.name = val.name(),
.description = val.description(),
.group = val.valGroup(),
.type_name = val.childType(),
.type_alias = if (!mem.eql(u8, val.childTypeName(), val.childType())) val.childTypeName() else null,
.set_behavior = @tagName(val.setBehavior()),
.max_entries = val.maxEntries(),
};
}
};
}
/// Meta Info Template
pub const MetaInfoTemplate = struct{
/// Name of the program.
name: ?[]const u8 = null,
/// Description of the program.
description: ?[]const u8 = null,
/// Version of the program.
version: ?[]const u8 = null,
/// Date of the program version.
ver_date: ?[]const u8 = null,
/// Author of the program.
author: ?[]const u8 = null,
/// Copyright info.
copyright: ?[]const u8 = null,
};
/// Config for creating Argument Templates with `createArgTemplate()`.
pub const ArgTemplateConfig = struct{
/// Script Local Filepath
/// This is the local path the file will be placed in. The file name will be "`name`-template.`template_kind`".
local_filepath: []const u8 = "meta/arg_templates",
/// Name of the program.
/// Note, if this is left null, the provided CommandT's name will be used.
name: ?[]const u8 = null,
/// Description of the program.
/// Note, if this is left null, the provided CommandT's description will be used.
description: ?[]const u8 = null,
/// Version of the program.
version: ?[]const u8 = null,
/// Date of the program version.
ver_date: ?[]const u8 = null,
/// Author of the program.
author: ?[]const u8 = null,
/// Copyright info.
copyright: ?[]const u8 = null,
/// Include Commands for Argument Templates.
include_cmds: bool = true,
/// Include Options for Argument Templates.
include_opts: bool = true,
/// Include Values for Argument Templates.
include_vals: bool = true,
/// Available Kinds of Argument Template formats.
pub const TemplateKind = enum{
json,
kdl,
};
};
/// Create an Argument Template.
pub fn createArgTemplate(
comptime CommandT: type,
comptime cmd: CommandT,
comptime at_config: ArgTemplateConfig,
comptime at_kind: ArgTemplateConfig.TemplateKind
) !void {
const at_name = at_config.name orelse cmd.name;
const at_description = at_config.description orelse cmd.description;
const filepath = genFilepath: {
comptime var path = if (at_config.local_filepath.len >= 0) at_config.local_filepath else ".";
comptime { if (mem.indexOfScalar(u8, &.{ '/', '\\' }, path[path.len - 1]) == null) path = path ++ "/"; }
try fs.cwd().makePath(path);
break :genFilepath path ++ at_name ++ "-template." ++ @tagName(at_kind);
};
var arg_template = try fs.cwd().createFile(filepath, .{});
var at_writer_parent = arg_template.writer(&.{});
const at_writer = &at_writer_parent.interface;
defer arg_template.close();
const meta_info_template = MetaInfoTemplate{
.name = at_name,
.description = at_description,
.version = at_config.version,
.ver_date = at_config.ver_date,
.author = at_config.author,
.copyright = at_config.copyright,
};
const cmd_template = CommandTemplate(CommandT).from(cmd, at_config);
const at_ctx = ArgTemplateContext{
.include_cmds = at_config.include_cmds,
.include_opts = at_config.include_opts,
.include_vals = at_config.include_vals,
};
switch (at_kind) {
.json => {
const json_opts_config: json.Stringify.Options = .{
.whitespace = .indent_4,
.emit_null_optional_fields = false,
};
try at_writer.print("\"Meta Info\": ", .{});
try json.Stringify.value(
meta_info_template,
json_opts_config,
at_writer,
);
try at_writer.print(",\n\"Arguments\": ", .{});
try json.Stringify.value(
cmd_template,
json_opts_config,
at_writer,
);
},
.kdl => {
try at_writer.print("# This KDL template is formatted to match the `usage` tool as detailed here: https://sr.ht/~jdx/usage/\n\n", .{});
try at_writer.print(
\\name "{s}"
\\bin "{s}"
\\about "{s}"
\\
, .{
at_name,
at_name,
at_description,
}
);
if (at_config.version) |ver| try at_writer.print("version \"{s}\"\n", .{ ver });
if (at_config.author) |author| try at_writer.print("author \"{s}\"\n", .{ author });
try at_writer.print("\n", .{});
try argTemplateKDL(
CommandT,
cmd,
at_writer,
at_ctx,
);
},
}
log.info("Generated '{s}' Argument Template for '{s}' into '{s}'.", .{
@tagName(at_kind),
cmd.name,
filepath,
});
}
pub const ArgTemplateContext = struct{
/// Argument Index
idx: u8 = 0,
/// Add a spacer line
add_line: bool = false,
/// Include Commands for Argument Templates.
include_cmds: bool = true,
/// Include Options for Argument Templates.
include_opts: bool = true,
/// Include Values for Argument Templates.
include_vals: bool = true,
};
/// Writes a Argument Template in the KDL for the provided CommandT (`cmd`) to the given Writer (`at_writer`).
/// This function passes the provided ArgumentTemplateContext (`at_ctx`) to track info through recursive calls.
fn argTemplateKDL(
comptime CommandT: type,
comptime cmd: CommandT,
at_writer: anytype,
comptime at_ctx: ArgTemplateContext,
) !void {
const sub_args: bool = (
(at_ctx.include_cmds and cmd.sub_cmds != null) or
(at_ctx.include_opts and cmd.opts != null) or
(at_ctx.include_vals and cmd.vals != null) or
cmd.alias_names != null
);
// if (sub_args and at_ctx.add_line) try at_writer.print("\n", .{});
if (at_ctx.add_line) try at_writer.print("\n", .{});
const indent = if (at_ctx.idx > 1) " " ** (at_ctx.idx - 1) else "";
const sub_indent = if (at_ctx.idx > 0) " " ** (at_ctx.idx) else "";
if (at_ctx.idx > 0) {
try at_writer.print("{s}cmd \"{s}\" help=\"{s}\"{s}\n", .{
indent,
cmd.name,
cmd.description,
if (sub_args) " {" else "",
});
}
var add_line = false;
if (cmd.alias_names) |aliases| addAliases: {
if (at_ctx.idx == 0) break :addAliases;
inline for (aliases) |alias| try at_writer.print("{s}alias \"{s}\"\n", .{ sub_indent, alias });
add_line = true;
}
if (at_ctx.include_opts) addOpts: {
const opts = cmd.opts orelse {
add_line = false;
break :addOpts;
};
if (add_line) try at_writer.print("\n", .{});
// TODO Better handling of prefixes. Check if the usage tool supports alternate prefixes.
inline for (opts) |opt| try at_writer.print("{s}flag \"{s}{s}\" help=\"{s}\"\n", .{
sub_indent,
if (opt.short_name) |short| fmt.comptimePrint("-{c},", .{ short }) else "",
if (opt.long_name) |long| fmt.comptimePrint("--{s}", .{ long }) else "",
opt.description,
});
add_line = true;
}
if (at_ctx.include_vals) addVals: {
const vals = cmd.vals orelse {
add_line = false;
break :addVals;
};
if (add_line) try at_writer.print("\n", .{});
inline for (vals) |val| try at_writer.print("{s}arg \"{s}\" help=\"{s}\"\n", .{
sub_indent,
val.name(),
val.description(),
});
add_line = true;
}
if (at_ctx.include_cmds) addCmds: {
const sub_cmds = cmd.sub_cmds orelse {
add_line = false;
break :addCmds;
};
if (add_line) try at_writer.print("\n", .{});
inline for (sub_cmds, 0..) |sub_cmd, idx| {
comptime var sub_ctx = at_ctx;
sub_ctx.idx += 1;
sub_ctx.add_line = idx > 0;
try argTemplateKDL(CommandT, sub_cmd, at_writer, sub_ctx);
}
}
if (at_ctx.idx > 0 and sub_args) try at_writer.print("{s}}}\n", .{ indent });
}
| 13,795 | arg_template | zig | en | zig | code | {"qsc_code_num_words": 1558, "qsc_code_num_chars": 13795.0, "qsc_code_mean_word_length": 4.7182285, "qsc_code_frac_words_unique": 0.13928113, "qsc_code_frac_chars_top_2grams": 0.03047204, "qsc_code_frac_chars_top_3grams": 0.02543872, "qsc_code_frac_chars_top_4grams": 0.03700177, "qsc_code_frac_chars_dupe_5grams": 0.3283907, "qsc_code_frac_chars_dupe_6grams": 0.24948987, "qsc_code_frac_chars_dupe_7grams": 0.22894844, "qsc_code_frac_chars_dupe_8grams": 0.18392056, "qsc_code_frac_chars_dupe_9grams": 0.15344851, "qsc_code_frac_chars_dupe_10grams": 0.14555843, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00620786, "qsc_code_frac_chars_whitespace": 0.32272563, "qsc_code_size_file_byte": 13795.0, "qsc_code_num_lines": 388.0, "qsc_code_num_chars_line_max": 148.0, "qsc_code_num_chars_line_mean": 35.55412371, "qsc_code_frac_chars_alphabet": 0.78058439, "qsc_code_frac_chars_comments": 0.17557086, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.33448276, "qsc_code_cate_autogen": 1.0, "qsc_code_frac_lines_long_string": 0.00344828, "qsc_code_frac_chars_string_length": 0.0309505, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.00257732, "qsc_code_frac_lines_assert": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 1, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Grim.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class Grim extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
int level = Math.max( 0, weapon.level() );
int enemyHealth = defender.HP - damage;
if (enemyHealth <= 0) return damage; //no point in proccing if they're already dead.
//scales from 0 - 50% based on how low hp the enemy is, plus 5% per level
float maxChance = 0.5f + .05f*level;
float chanceMulti = (float)Math.pow( ((defender.HT - enemyHealth) / (float)defender.HT), 2);
float chance = maxChance * chanceMulti;
if (Random.Float() < chance) {
defender.damage( defender.HP, this );
defender.sprite.emitter().burst( ShadowParticle.UP, 5 );
if (!defender.isAlive() && attacker instanceof Hero
//this prevents unstable from triggering grim achievement
&& weapon.hasEnchant(Grim.class, attacker)) {
Badges.validateGrimWeapon();
}
}
return damage;
}
@Override
public Glowing glowing() {
return BLACK;
}
}
| 2,461 | Grim | java | en | java | code | {"qsc_code_num_words": 313, "qsc_code_num_chars": 2461.0, "qsc_code_mean_word_length": 5.88498403, "qsc_code_frac_words_unique": 0.51118211, "qsc_code_frac_chars_top_2grams": 0.07383279, "qsc_code_frac_chars_top_3grams": 0.165038, "qsc_code_frac_chars_top_4grams": 0.16720955, "qsc_code_frac_chars_dupe_5grams": 0.21824104, "qsc_code_frac_chars_dupe_6grams": 0.09663409, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01742498, "qsc_code_frac_chars_whitespace": 0.16050386, "qsc_code_size_file_byte": 2461.0, "qsc_code_num_lines": 70.0, "qsc_code_num_chars_line_max": 95.0, "qsc_code_num_chars_line_mean": 35.15714286, "qsc_code_frac_chars_alphabet": 0.87415295, "qsc_code_frac_chars_comments": 0.38927265, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.05882353, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00532269, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.05882353, "qsc_codejava_score_lines_no_logic": 0.38235294, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blocking.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2018 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Blocking extends Weapon.Enchantment {
private static ItemSprite.Glowing BLUE = new ItemSprite.Glowing( 0x0000FF );
@Override
public int proc(Weapon weapon, Char attacker, Char defender, int damage) {
int level = Math.max( 0, weapon.level() );
Buff.prolong(attacker, BlockBuff.class, 2 + level/2).setBlocking(level + 1);
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return BLUE;
}
public static class BlockBuff extends FlavourBuff {
private int blocking = 0;
public void setBlocking( int blocking ){
this.blocking = blocking;
}
public int blockingRoll(){
return Random.NormalIntRange(0, blocking);
}
@Override
public int icon() {
return BuffIndicator.ARMOR;
}
@Override
public void tintIcon(Image icon) {
icon.tint(0, 0.5f, 1, 0.5f);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", blocking, dispTurns());
}
private static final String BLOCKING = "blocking";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(BLOCKING, blocking);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
blocking = bundle.getInt(BLOCKING);
}
}
}
| 2,808 | Blocking | java | en | java | code | {"qsc_code_num_words": 341, "qsc_code_num_chars": 2808.0, "qsc_code_mean_word_length": 6.09970674, "qsc_code_frac_words_unique": 0.4340176, "qsc_code_frac_chars_top_2grams": 0.04326923, "qsc_code_frac_chars_top_3grams": 0.14615385, "qsc_code_frac_chars_top_4grams": 0.14807692, "qsc_code_frac_chars_dupe_5grams": 0.19615385, "qsc_code_frac_chars_dupe_6grams": 0.07980769, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01456727, "qsc_code_frac_chars_whitespace": 0.16880342, "qsc_code_size_file_byte": 2808.0, "qsc_code_num_lines": 101.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 27.8019802, "qsc_code_frac_chars_alphabet": 0.87660668, "qsc_code_frac_chars_comments": 0.27777778, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13333333, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00788955, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00394477, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.15, "qsc_codejava_score_lines_no_logic": 0.36666667, "qsc_codejava_frac_words_no_modifier": 0.9, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Lucky.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class Lucky extends Weapon.Enchantment {
private static ItemSprite.Glowing GREEN = new ItemSprite.Glowing( 0x00FF00 );
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
int level = Math.max( 0, weapon.level() );
// lvl 0 - 10%
// lvl 1 ~ 12%
// lvl 2 ~ 14%
if (defender.HP <= damage
&& Random.Int( level + 40 ) >= 36){
Buff.affect(defender, LuckProc.class);
}
return damage;
}
public static Item genLoot(){
float roll = Random.Float();
if (roll < 0.6f){
Item result = new Gold().random();
result.quantity(Math.round(result.quantity() * 0.5f));
return result;
} else if (roll < 0.9f){
return Random.Int(2) == 0
? Generator.random(Generator.Category.SEED)
: Generator.random(Generator.Category.STONE);
} else {
return Random.Int(2) == 0
? Generator.random(Generator.Category.POTION)
: Generator.random(Generator.Category.SCROLL);
}
}
@Override
public Glowing glowing() {
return GREEN;
}
//used to keep track of whether a luck proc is incoming. see Mob.die()
public static class LuckProc extends Buff {
@Override
public boolean act() {
detach();
return true;
}
}
}
| 2,635 | Lucky | java | en | java | code | {"qsc_code_num_words": 339, "qsc_code_num_chars": 2635.0, "qsc_code_mean_word_length": 5.67846608, "qsc_code_frac_words_unique": 0.4660767, "qsc_code_frac_chars_top_2grams": 0.07948052, "qsc_code_frac_chars_top_3grams": 0.17766234, "qsc_code_frac_chars_top_4grams": 0.18285714, "qsc_code_frac_chars_dupe_5grams": 0.33922078, "qsc_code_frac_chars_dupe_6grams": 0.14337662, "qsc_code_frac_chars_dupe_7grams": 0.05090909, "qsc_code_frac_chars_dupe_8grams": 0.05090909, "qsc_code_frac_chars_dupe_9grams": 0.05090909, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02100457, "qsc_code_frac_chars_whitespace": 0.16888046, "qsc_code_size_file_byte": 2635.0, "qsc_code_num_lines": 85.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 31.0, "qsc_code_frac_chars_alphabet": 0.85799087, "qsc_code_frac_chars_comments": 0.33889943, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.10204082, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00459242, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.08163265, "qsc_codejava_score_lines_no_logic": 0.36734694, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Projecting.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
public class Projecting extends Weapon.Enchantment {
private static ItemSprite.Glowing PURPLE = new ItemSprite.Glowing( 0x8844CC );
@Override
public int proc(Weapon weapon, Char attacker, Char defender, int damage) {
//Does nothing as a proc, instead increases weapon range.
//See weapon.reachFactor, and MissileWeapon.throwPos;
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return PURPLE;
}
}
| 1,490 | Projecting | java | en | java | code | {"qsc_code_num_words": 198, "qsc_code_num_chars": 1490.0, "qsc_code_mean_word_length": 5.78787879, "qsc_code_frac_words_unique": 0.58080808, "qsc_code_frac_chars_top_2grams": 0.05933682, "qsc_code_frac_chars_top_3grams": 0.13263525, "qsc_code_frac_chars_top_4grams": 0.04973822, "qsc_code_frac_chars_dupe_5grams": 0.15706806, "qsc_code_frac_chars_dupe_6grams": 0.04886562, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01755786, "qsc_code_frac_chars_whitespace": 0.1590604, "qsc_code_size_file_byte": 1490.0, "qsc_code_num_lines": 43.0, "qsc_code_num_chars_line_max": 80.0, "qsc_code_num_chars_line_mean": 34.65116279, "qsc_code_frac_chars_alphabet": 0.89704709, "qsc_code_frac_chars_comments": 0.59798658, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13333333, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.01335559, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.46666667, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Unstable.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
import com.watabou.utils.Reflection;
public class Unstable extends Weapon.Enchantment {
private static ItemSprite.Glowing GREY = new ItemSprite.Glowing( 0x999999 );
private static Class<?extends Weapon.Enchantment>[] randomEnchants = new Class[]{
Blazing.class,
Blocking.class,
Blooming.class,
Chilling.class,
Kinetic.class,
Corrupting.class,
Elastic.class,
Grim.class,
Lucky.class,
//projecting not included, no on-hit effect
Shocking.class,
Vampiric.class
};
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
int conservedDamage = 0;
if (attacker.buff(Kinetic.ConservedDamage.class) != null) {
conservedDamage = attacker.buff(Kinetic.ConservedDamage.class).damageBonus();
attacker.buff(Kinetic.ConservedDamage.class).detach();
}
damage = Reflection.newInstance(Random.oneOf(randomEnchants)).proc( weapon, attacker, defender, damage );
return damage + conservedDamage;
}
@Override
public ItemSprite.Glowing glowing() {
return GREY;
}
}
| 2,141 | Unstable | java | en | java | code | {"qsc_code_num_words": 266, "qsc_code_num_chars": 2141.0, "qsc_code_mean_word_length": 6.07142857, "qsc_code_frac_words_unique": 0.51503759, "qsc_code_frac_chars_top_2grams": 0.02786378, "qsc_code_frac_chars_top_3grams": 0.09411765, "qsc_code_frac_chars_top_4grams": 0.03529412, "qsc_code_frac_chars_dupe_5grams": 0.18390093, "qsc_code_frac_chars_dupe_6grams": 0.03467492, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01385809, "qsc_code_frac_chars_whitespace": 0.15740308, "qsc_code_size_file_byte": 2141.0, "qsc_code_num_lines": 66.0, "qsc_code_num_chars_line_max": 108.0, "qsc_code_num_chars_line_mean": 32.43939394, "qsc_code_frac_chars_alphabet": 0.88137472, "qsc_code_frac_chars_comments": 0.38486688, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.05555556, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00607441, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.02777778, "qsc_codejava_score_lines_no_logic": 0.22222222, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
0-1-0/lightblue-0.4 | src/series60/_lightblue.py | # Copyright (c) 2009 Bea Lam. All rights reserved.
#
# This file is part of LightBlue.
#
# LightBlue 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 3 of the License, or
# (at your option) any later version.
#
# LightBlue is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
import socket as _socket
import _lightbluecommon
# public attributes
__all__ = ("finddevices", "findservices", "finddevicename",
"gethostaddr", "gethostclass",
"socket",
"advertise", "stopadvertise",
"selectdevice", "selectservice")
# details of advertised services
__advertised = {}
def finddevices(getnames=True, length=10):
# originally this used DiscoverDevices in _lightblueutil extension, but
# that blocks the UI
import e32
inquiry = _DeviceInquiry()
inquiry.start(getnames, length)
timer = None
try:
while not inquiry.isdone():
# keep waiting
timer = e32.Ao_timer()
timer.after(0.1)
finally:
inquiry.stop()
if timer is not None: timer.cancel()
return inquiry.getfounddevices()
def findservices(addr=None, name=None, servicetype=None):
if servicetype is None:
funcs = (_socket.bt_discover, _socket.bt_obex_discover)
elif servicetype == _lightbluecommon.RFCOMM:
funcs = (_socket.bt_discover, )
elif servicetype == _lightbluecommon.OBEX:
funcs = (_socket.bt_obex_discover, )
else:
raise ValueError("servicetype must be RFCOMM, OBEX or None, was %s" % \
servicetype)
if addr is None:
devices = finddevices()
btaddrs = [d[0] for d in devices]
else:
btaddrs = [addr]
services = []
for addr in btaddrs:
for func in funcs:
try:
devaddr, servicesdict = func(addr)
except _socket.error, e:
#raise _lightbluecommon.BluetoothError(str(e))
print "[lightblue] cannot look up services for %s" % addr
continue
if name is not None:
for servicename in servicesdict.keys():
if servicename != name:
del servicesdict[servicename]
services.extend(_getservicetuples(devaddr, servicesdict))
return services
def finddevicename(address, usecache=True):
if not _lightbluecommon._isbtaddr(address):
raise ValueError("%s is not a valid bluetooth address" % str(address))
if address == gethostaddr():
return _gethostname()
try:
# lookupName() expects address without colon separators
import _lightblueutil
address_no_sep = address.replace(":", "").replace("-", "")
name = _lightblueutil.lookupName(address_no_sep, (not usecache))
except SymbianError, e:
raise _lightbluecommon.BluetoothError(
"Cannot find device name for %s: %s" % (address, str(e)))
return name
def gethostaddr():
import _lightblueutil
try:
addr = _lightblueutil.getLocalAddress()
except SymbianError, exc:
raise _lightbluecommon.BluetoothError(
"Cannot read local device address: " + str(exc))
return addr
def gethostclass():
import _lightblueutil
try:
cod = _lightblueutil.getLocalDeviceClass()
except SymbianError, exc:
raise _lightbluecommon.BluetoothError(
"Cannot read local device class: " + str(exc))
return cod
def _gethostname():
import _lightblueutil
try:
name = _lightblueutil.getLocalName()
except SymbianError, exc:
raise _lightbluecommon.BluetoothError(
"Cannot read local device name: " + str(exc))
return name
class _SocketWrapper(object):
def __init__(self, sock, connaddr=()):
self.__dict__["_sock"] = sock
self._setconnaddr(connaddr)
# must implement accept() to return _SocketWrapper objects
def accept(self):
conn, addr = self._sock.accept()
# modify returned address cos PyS60 accept() only returns address, not
# (addr, channel) tuple
addrtuple = (addr.upper(), self._connaddr[1])
return (_SocketWrapper(conn, addrtuple), addrtuple)
accept.__doc__ = _lightbluecommon._socketdocs["accept"]
def bind(self, addr):
# if port==0, find an available port
if addr[1] == 0:
addr = (addr[0], _getavailableport(self))
try:
self._sock.bind(addr)
except Exception, e:
raise _socket.error(str(e))
self._setconnaddr(addr)
bind.__doc__ = _lightbluecommon._socketdocs["bind"]
def close(self):
self._sock.close()
# try to stop advertising
try:
stopadvertise(self)
except:
pass
close.__doc__ = _lightbluecommon._socketdocs["close"]
def connect(self, addr):
self._sock.connect(addr)
self._setconnaddr(addr)
connect.__doc__ = _lightbluecommon._socketdocs["connect"]
def connect_ex(self, addr):
try:
self.connect(addr)
except _socket.error, e:
return e.args[0]
return 0
connect_ex.__doc__ = _lightbluecommon._socketdocs["connect_ex"]
# must implement dup() to return _SocketWrapper objects
def dup(self):
return _SocketWrapper(self._sock.dup())
dup.__doc__ = _lightbluecommon._socketdocs["dup"]
def listen(self, backlog):
self._sock.listen(backlog)
# when listen() is called, set a default security level since S60
# sockets are required to have a security level
# This should be changed later to allow to set security using
# setsockopt()
_socket.set_security(self._sock, _socket.AUTH)
listen.__doc__ = _lightbluecommon._socketdocs["listen"]
# PyS60 raises socket.error("Bad protocol") when this is called for stream
# sockets, but implement it here like recv() for consistency with Linux+Mac
def recvfrom(self, bufsize, flags=0):
return (self._sock.recv(bufsize, flags), None)
recvfrom.__doc__ = _lightbluecommon._socketdocs["recvfrom"]
# PyS60 raises socket.error("Bad protocol") when this is called for stream
# sockets, but implement it here like send() for consistency with Linux+Mac
def sendto(self, data, *extra):
if len(extra) == 1:
address = extra[0]
flags = 0
elif len(extra) == 2:
flags, address = extra
else:
raise TypeError("sendto takes at most 3 arguments (%d given)" % \
(len(extra) + 1))
return self._sock.send(data, flags)
sendto.__doc__ = _lightbluecommon._socketdocs["sendto"]
# sendall should return None on success but PyS60 seems to have it return
# bytes sent like send
def sendall(self, data, flags=0):
self.send(data, flags)
return None
sendall.__doc__ = _lightbluecommon._socketdocs["sendall"]
# implement to return (remote-address, common-channel) like PyBluez
# (PyS60 implementation raises error when this method is called, saying
# it's not implemented - maybe cos a remote BT socket doesn't really have
# an outgoing channel like TCP sockets? But it seems handy to return the
# channel we're communicating over anyway i.e. the local RFCOMM channel)
def getpeername(self):
if not self._connaddr:
raise _socket.error(57, "Socket is not connected")
return self._connaddr
getpeername.__doc__ = _lightbluecommon._socketdocs["getpeername"]
# like getpeername(), PyS60 does not implement this method
def getsockname(self):
if not self._connaddr: # sock is neither bound nor connected
return ("00:00:00:00:00:00", 0)
return (gethostaddr(), self._connaddr[1])
getsockname.__doc__ = _lightbluecommon._socketdocs["getsockname"]
def fileno(self):
raise NotImplementedError
fileno.__doc__ = _lightbluecommon._socketdocs["fileno"]
def settimeout(self, timeout):
raise NotImplementedError
settimeout.__doc__ = _lightbluecommon._socketdocs["settimeout"]
def gettimeout(self):
return None
gettimeout.__doc__ = _lightbluecommon._socketdocs["gettimeout"]
def _setconnaddr(self, connaddr):
if len(connaddr) == 2:
connaddr = (connaddr[0].upper(), connaddr[1])
self.__dict__["_connaddr"] = connaddr
# wrap all other socket methods, to set LightBlue-specific docstrings
_othermethods = [_m for _m in _lightbluecommon._socketdocs.keys() \
if _m not in locals()] # methods other than those already defined
_methoddef = """def %s(self, *args, **kwargs):
return self._sock.%s(*args, **kwargs)
%s.__doc__ = _lightbluecommon._socketdocs['%s']\n"""
for _m in _othermethods:
exec _methoddef % (_m, _m, _m, _m)
del _m, _methoddef
def socket(proto=_lightbluecommon.RFCOMM):
if proto == _lightbluecommon.L2CAP:
raise NotImplementedError("L2CAP sockets not supported on this platform")
sock = _socket.socket(_socket.AF_BT, _socket.SOCK_STREAM,
_socket.BTPROTO_RFCOMM)
return _SocketWrapper(sock)
def _getavailableport(sock):
# can just use bt_rfcomm_get_available_server_channel since only RFCOMM is
# currently supported
return _socket.bt_rfcomm_get_available_server_channel(sock._sock)
def advertise(name, sock, servicetype):
if servicetype == _lightbluecommon.RFCOMM:
servicetype = _socket.RFCOMM
elif servicetype == _lightbluecommon.OBEX:
servicetype = _socket.OBEX
else:
raise ValueError("servicetype must be either RFCOMM or OBEX")
name = unicode(name)
# advertise the service
_socket.bt_advertise_service(name, sock._sock, True, servicetype)
# note details, for if advertising needs to be stopped later
__advertised[id(sock)] = (name, servicetype)
def stopadvertise(sock):
details = __advertised.get(id(sock))
if details is None:
raise _lightbluecommon.BluetoothError("no service advertised")
name, servicetype = details
_socket.bt_advertise_service(name, sock._sock, False, servicetype)
def selectdevice():
import _lightblueutil
try:
result = _lightblueutil.selectDevice()
except SymbianError, e:
raise _lightbluecommon.BluetoothError(str(e))
# underlying method returns class of device as tuple, not whole class
devinfo = (result[0], result[1], _lightbluecommon._joinclass(result[2]))
return devinfo
def selectservice():
device = selectdevice()
if device is None:
return None
import appuifw
services = findservices(addr=device[0])
choice = appuifw.popup_menu(
[unicode("%d: %s" % (s[1], s[2])) for s in services],
u"Choose service:")
if choice is None:
return None
return services[choice]
# Returns a list of (addr, channel, name) service tuples from a device
# address and a dictionary of {name: channel} mappings.
def _getservicetuples(devaddr, servicesdict):
return [(devaddr.upper(), channel, name) for name, channel in servicesdict.items()]
class _DeviceInquiry(object):
def __init__(self):
super(_DeviceInquiry, self).__init__()
self._founddevices = []
self._resolver = None
self._done = False
def start(self, getnames, length):
self._founddevices = []
self._done = False
import _lightblueutil
self._resolver = _lightblueutil.AoResolver()
self._resolver.open()
self._resolver.discover(self._founddevice, None, getnames)
def isdone(self):
return self._done
def stop(self):
if self.isdone():
return
if self._resolver:
self._resolver.cancel()
self._resolver.close()
self._done = True
def getfounddevices(self):
return self._founddevices[:]
def _founddevice(self, err, addr, name, devclass, param):
try:
if err == 0: # no err
#print "Found device", addr
# PDIS AoResolver returns addres without the colons
addr = addr[0:2] + ":" + addr[2:4] + ":" + addr[4:6] + ":" + \
addr[6:8] + ":" + addr[8:10] + ":" + addr[10:12]
devinfo = (addr.encode("utf-8").upper(),
name,
_lightbluecommon._joinclass(devclass))
self._founddevices.append(devinfo)
# keep looking for devices
self._resolver.next()
else:
if err == -25: # KErrEof (no more devices)
# finished discovery
self._resolver.close()
self._done = True
else:
print "[lightblue] device discovery error (%d)" % err
except Exception, e:
# catch all exceptions, the app will crash if exception is raised
# during callback
print "Error during _founddevice() callback: "+ str(e)
| 14,171 | _lightblue | py | en | python | code | {"qsc_code_num_words": 1515, "qsc_code_num_chars": 14171.0, "qsc_code_mean_word_length": 5.55247525, "qsc_code_frac_words_unique": 0.25478548, "qsc_code_frac_chars_top_2grams": 0.05052306, "qsc_code_frac_chars_top_3grams": 0.05325725, "qsc_code_frac_chars_top_4grams": 0.01902045, "qsc_code_frac_chars_dupe_5grams": 0.13290537, "qsc_code_frac_chars_dupe_6grams": 0.11091298, "qsc_code_frac_chars_dupe_7grams": 0.05634807, "qsc_code_frac_chars_dupe_8grams": 0.04778887, "qsc_code_frac_chars_dupe_9grams": 0.04778887, "qsc_code_frac_chars_dupe_10grams": 0.04778887, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00893574, "qsc_code_frac_chars_whitespace": 0.29715616, "qsc_code_size_file_byte": 14171.0, "qsc_code_num_lines": 391.0, "qsc_code_num_chars_line_max": 88.0, "qsc_code_num_chars_line_mean": 36.24296675, "qsc_code_frac_chars_alphabet": 0.83564257, "qsc_code_frac_chars_comments": 0.20838332, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.21722846, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.08300466, "qsc_code_frac_chars_long_word_length": 0.00322696, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codepython_cate_ast": 0.0, "qsc_codepython_frac_lines_func_ratio": null, "qsc_codepython_cate_var_zero": null, "qsc_codepython_frac_lines_pass": 0.00374532, "qsc_codepython_frac_lines_import": 0.03745318, "qsc_codepython_frac_lines_simplefunc": null, "qsc_codepython_score_lines_no_logic": null, "qsc_codepython_frac_lines_print": 0.01123596} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codepython_cate_ast": 1, "qsc_codepython_frac_lines_func_ratio": 0, "qsc_codepython_cate_var_zero": 0, "qsc_codepython_frac_lines_pass": 0, "qsc_codepython_frac_lines_import": 0, "qsc_codepython_frac_lines_simplefunc": 0, "qsc_codepython_score_lines_no_logic": 0, "qsc_codepython_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LockedFloor;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTransmutation;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ExoticScroll;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
import com.watabou.utils.Reflection;
import java.util.ArrayList;
import java.util.Collections;
public class UnstableSpellbook extends Artifact {
{
image = ItemSpriteSheet.ARTIFACT_SPELLBOOK;
levelCap = 10;
charge = (int)(level()*0.6f)+2;
partialCharge = 0;
chargeCap = (int)(level()*0.6f)+2;
defaultAction = AC_READ;
}
public static final String AC_READ = "READ";
public static final String AC_ADD = "ADD";
private final ArrayList<Class> scrolls = new ArrayList<>();
protected WndBag.Mode mode = WndBag.Mode.SCROLL;
public UnstableSpellbook() {
super();
Class<?>[] scrollClasses = Generator.Category.SCROLL.classes;
float[] probs = Generator.Category.SCROLL.probs.clone(); //array of primitives, clone gives deep copy.
int i = Random.chances(probs);
while (i != -1){
scrolls.add(scrollClasses[i]);
probs[i] = 0;
i = Random.chances(probs);
}
scrolls.remove(ScrollOfTransmutation.class);
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
if (isEquipped( hero ) && charge > 0 && !cursed)
actions.add(AC_READ);
if (isEquipped( hero ) && level() < levelCap && !cursed)
actions.add(AC_ADD);
return actions;
}
@Override
public void execute( Hero hero, String action ) {
super.execute( hero, action );
if (action.equals( AC_READ )) {
if (hero.buff( Blindness.class ) != null) GLog.w( Messages.get(this, "blinded") );
else if (!isEquipped( hero )) GLog.i( Messages.get(Artifact.class, "need_to_equip") );
else if (charge <= 0) GLog.i( Messages.get(this, "no_charge") );
else if (cursed) GLog.i( Messages.get(this, "cursed") );
else {
charge--;
Scroll scroll;
do {
scroll = (Scroll) Generator.random(Generator.Category.SCROLL);
} while (scroll == null
//reduce the frequency of these scrolls by half
||((scroll instanceof ScrollOfIdentify ||
scroll instanceof ScrollOfRemoveCurse ||
scroll instanceof ScrollOfMagicMapping) && Random.Int(2) == 0)
//don't roll teleportation scrolls on boss floors
|| (scroll instanceof ScrollOfTeleportation && Dungeon.bossLevel())
|| (scroll instanceof ScrollOfTransmutation));
scroll.anonymize();
curItem = scroll;
curUser = hero;
//if there are changes left and the scroll has been given to the book
if (charge > 0 && !scrolls.contains(scroll.getClass())) {
final Scroll fScroll = scroll;
GameScene.show(new WndOptions(
Messages.get(this, "prompt"),
Messages.get(this, "read_empowered"),
scroll.trueName(),
Messages.get(ExoticScroll.regToExo.get(scroll.getClass()), "name")){
@Override
protected void onSelect(int index) {
if (index == 1){
Scroll scroll = Reflection.newInstance(ExoticScroll.regToExo.get(fScroll.getClass()));
charge--;
scroll.doRead();
} else {
fScroll.doRead();
}
}
@Override
public void onBackPressed() {
//do nothing
}
});
} else {
scroll.doRead();
}
updateQuickslot();
}
} else if (action.equals( AC_ADD )) {
GameScene.selectItem(itemSelector, mode, Messages.get(this, "prompt"));
}
}
@Override
protected ArtifactBuff passiveBuff() {
return new bookRecharge();
}
@Override
public void charge(Hero target) {
if (charge < chargeCap){
partialCharge += 0.1f;
if (partialCharge >= 1){
partialCharge--;
charge++;
updateQuickslot();
}
}
}
@Override
public Item upgrade() {
chargeCap = (int)((level()+1)*0.6f)+2;
//for artifact transmutation.
while (!scrolls.isEmpty() && scrolls.size() > (levelCap-1-level()))
scrolls.remove(0);
return super.upgrade();
}
@Override
public String desc() {
String desc = super.desc();
if (isEquipped(Dungeon.hero)) {
if (cursed) {
desc += "\n\n" + Messages.get(this, "desc_cursed");
}
if (level() < levelCap && scrolls.size() > 0) {
desc += "\n\n" + Messages.get(this, "desc_index");
desc += "\n" + "_" + Messages.get(scrolls.get(0), "name") + "_";
if (scrolls.size() > 1)
desc += "\n" + "_" + Messages.get(scrolls.get(1), "name") + "_";
}
}
if (level() > 0) {
desc += "\n\n" + Messages.get(this, "desc_empowered");
}
return desc;
}
private static final String SCROLLS = "scrolls";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle(bundle);
bundle.put( SCROLLS, scrolls.toArray(new Class[scrolls.size()]) );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle(bundle);
scrolls.clear();
Collections.addAll(scrolls, bundle.getClassArray(SCROLLS));
}
public class bookRecharge extends ArtifactBuff{
@Override
public boolean act() {
LockedFloor lock = target.buff(LockedFloor.class);
if (charge < chargeCap && !cursed && (lock == null || lock.regenOn())) {
partialCharge += 1 / (120f - (chargeCap - charge)*5f);
if (partialCharge >= 1) {
partialCharge --;
charge ++;
if (charge == chargeCap){
partialCharge = 0;
}
}
}
updateQuickslot();
spend( TICK );
return true;
}
}
protected WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect(Item item) {
if (item != null && item instanceof Scroll && item.isIdentified()){
Hero hero = Dungeon.hero;
for (int i = 0; ( i <= 1 && i < scrolls.size() ); i++){
if (scrolls.get(i).equals(item.getClass())){
hero.sprite.operate( hero.pos );
hero.busy();
hero.spend( 2f );
Sample.INSTANCE.play(Assets.SND_BURNING);
hero.sprite.emitter().burst( ElmoParticle.FACTORY, 12 );
scrolls.remove(i);
item.detach(hero.belongings.backpack);
upgrade();
GLog.i( Messages.get(UnstableSpellbook.class, "infuse_scroll") );
return;
}
}
GLog.w( Messages.get(UnstableSpellbook.class, "unable_scroll") );
} else if (item instanceof Scroll && !item.isIdentified())
GLog.w( Messages.get(UnstableSpellbook.class, "unknown_scroll") );
}
};
}
| 8,660 | UnstableSpellbook | java | en | java | code | {"qsc_code_num_words": 958, "qsc_code_num_chars": 8660.0, "qsc_code_mean_word_length": 6.18893528, "qsc_code_frac_words_unique": 0.29123173, "qsc_code_frac_chars_top_2grams": 0.03794906, "qsc_code_frac_chars_top_3grams": 0.14100186, "qsc_code_frac_chars_top_4grams": 0.15584416, "qsc_code_frac_chars_dupe_5grams": 0.23022432, "qsc_code_frac_chars_dupe_6grams": 0.13847192, "qsc_code_frac_chars_dupe_7grams": 0.01298701, "qsc_code_frac_chars_dupe_8grams": 0.00877045, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00849618, "qsc_code_frac_chars_whitespace": 0.18452656, "qsc_code_size_file_byte": 8660.0, "qsc_code_num_lines": 282.0, "qsc_code_num_chars_line_max": 105.0, "qsc_code_num_chars_line_mean": 30.70921986, "qsc_code_frac_chars_alphabet": 0.83106769, "qsc_code_frac_chars_comments": 0.11916859, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13744076, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.02385947, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.00947867, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.0521327, "qsc_codejava_score_lines_no_logic": 0.21327014, "qsc_codejava_frac_words_no_modifier": 0.84615385, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 0.5, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.CorrosiveGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Corruption;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LockedFloor;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Wraith;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Brimstone;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRetribution;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfPsionicBlast;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.GhostSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.ui.BossHealthBar;
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.IconTitle;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBlacksmith;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndItem;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndQuest;
import com.watabou.noosa.Game;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import com.watabou.utils.Callback;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
import java.util.ArrayList;
public class DriedRose extends Artifact {
{
image = ItemSpriteSheet.ARTIFACT_ROSE1;
levelCap = 10;
charge = 100;
chargeCap = 100;
defaultAction = AC_SUMMON;
}
private boolean talkedTo = false;
private boolean firstSummon = false;
private GhostHero ghost = null;
private int ghostID = 0;
private MeleeWeapon weapon = null;
private Armor armor = null;
public int droppedPetals = 0;
public static final String AC_SUMMON = "SUMMON";
public static final String AC_DIRECT = "DIRECT";
public static final String AC_OUTFIT = "OUTFIT";
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
if (!Ghost.Quest.completed()){
actions.remove(AC_EQUIP);
return actions;
}
if (isEquipped( hero ) && charge == chargeCap && !cursed && ghostID == 0) {
actions.add(AC_SUMMON);
}
if (ghostID != 0){
actions.add(AC_DIRECT);
}
if (isIdentified() && !cursed){
actions.add(AC_OUTFIT);
}
return actions;
}
@Override
public void execute( Hero hero, String action ) {
super.execute(hero, action);
if (action.equals(AC_SUMMON)) {
if (!Ghost.Quest.completed()) GameScene.show(new WndItem(null, this, true));
else if (ghost != null) GLog.i( Messages.get(this, "spawned") );
else if (!isEquipped( hero )) GLog.i( Messages.get(Artifact.class, "need_to_equip") );
else if (charge != chargeCap) GLog.i( Messages.get(this, "no_charge") );
else if (cursed) GLog.i( Messages.get(this, "cursed") );
else {
ArrayList<Integer> spawnPoints = new ArrayList<>();
for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
int p = hero.pos + PathFinder.NEIGHBOURS8[i];
if (Actor.findChar(p) == null && (Dungeon.level.passable[p] || Dungeon.level.avoid[p])) {
spawnPoints.add(p);
}
}
if (spawnPoints.size() > 0) {
ghost = new GhostHero( this );
ghostID = ghost.id();
ghost.pos = Random.element(spawnPoints);
GameScene.add(ghost, 1f);
Dungeon.level.occupyCell(ghost);
CellEmitter.get(ghost.pos).start( ShaftParticle.FACTORY, 0.3f, 4 );
CellEmitter.get(ghost.pos).start( Speck.factory(Speck.LIGHT), 0.2f, 3 );
hero.spend(1f);
hero.busy();
hero.sprite.operate(hero.pos);
if (!firstSummon) {
ghost.yell( Messages.get(GhostHero.class, "hello", Dungeon.hero.givenName()) );
Sample.INSTANCE.play( Assets.SND_GHOST );
firstSummon = true;
} else {
if (BossHealthBar.isAssigned()) {
ghost.sayBoss();
} else {
ghost.sayAppeared();
}
}
charge = 0;
partialCharge = 0;
updateQuickslot();
} else
GLog.i( Messages.get(this, "no_space") );
}
} else if (action.equals(AC_DIRECT)){
if (ghost == null && ghostID != 0){
Actor a = Actor.findById(ghostID);
if (a != null){
ghost = (GhostHero)a;
} else {
ghostID = 0;
}
}
if (ghost != null) GameScene.selectCell(ghostDirector);
} else if (action.equals(AC_OUTFIT)){
GameScene.show( new WndGhostHero(this) );
}
}
public int ghostStrength(){
return 13 + level()/2;
}
@Override
public String desc() {
if (!Ghost.Quest.completed() && !isIdentified()){
return Messages.get(this, "desc_no_quest");
}
String desc = super.desc();
if (isEquipped( Dungeon.hero )){
if (!cursed){
if (level() < levelCap)
desc+= "\n\n" + Messages.get(this, "desc_hint");
} else
desc += "\n\n" + Messages.get(this, "desc_cursed");
}
return desc;
}
@Override
public String status() {
if (ghost == null && ghostID != 0){
try {
Actor a = Actor.findById(ghostID);
if (a != null) {
ghost = (GhostHero) a;
} else {
ghostID = 0;
}
} catch ( ClassCastException e ){
ShatteredPixelDungeon.reportException(e);
ghostID = 0;
}
}
if (ghost == null){
return super.status();
} else {
return (int)((ghost.HP+partialCharge)*100) / ghost.HT + "%";
}
}
@Override
protected ArtifactBuff passiveBuff() {
return new roseRecharge();
}
@Override
public void charge(Hero target) {
if (ghost == null){
if (charge < chargeCap) {
charge += 4;
updateQuickslot();
if (charge >= chargeCap) {
charge = chargeCap;
partialCharge = 0;
GLog.p(Messages.get(DriedRose.class, "charged"));
}
}
} else {
ghost.HP = Math.min( ghost.HT, ghost.HP + 1 + level()/3);
updateQuickslot();
}
}
@Override
public Item upgrade() {
if (level() >= 9)
image = ItemSpriteSheet.ARTIFACT_ROSE3;
else if (level() >= 4)
image = ItemSpriteSheet.ARTIFACT_ROSE2;
//For upgrade transferring via well of transmutation
droppedPetals = Math.max( level(), droppedPetals );
if (ghost != null){
ghost.updateRose();
}
return super.upgrade();
}
public Weapon ghostWeapon(){
return weapon;
}
public Armor ghostArmor(){
return armor;
}
private static final String TALKEDTO = "talkedto";
private static final String FIRSTSUMMON = "firstsummon";
private static final String GHOSTID = "ghostID";
private static final String PETALS = "petals";
private static final String WEAPON = "weapon";
private static final String ARMOR = "armor";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle(bundle);
bundle.put( TALKEDTO, talkedTo );
bundle.put( FIRSTSUMMON, firstSummon );
bundle.put( GHOSTID, ghostID );
bundle.put( PETALS, droppedPetals );
if (weapon != null) bundle.put( WEAPON, weapon );
if (armor != null) bundle.put( ARMOR, armor );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle(bundle);
talkedTo = bundle.getBoolean( TALKEDTO );
firstSummon = bundle.getBoolean( FIRSTSUMMON );
ghostID = bundle.getInt( GHOSTID );
droppedPetals = bundle.getInt( PETALS );
if (ghostID != 0) defaultAction = AC_DIRECT;
if (bundle.contains(WEAPON)) weapon = (MeleeWeapon)bundle.get( WEAPON );
if (bundle.contains(ARMOR)) armor = (Armor)bundle.get( ARMOR );
}
public class roseRecharge extends ArtifactBuff {
@Override
public boolean act() {
spend( TICK );
if (ghost == null && ghostID != 0){
Actor a = Actor.findById(ghostID);
if (a != null){
ghost = (GhostHero)a;
} else {
ghostID = 0;
}
}
//rose does not charge while ghost hero is alive
if (ghost != null){
defaultAction = AC_DIRECT;
//heals to full over 1000 turns
if (ghost.HP < ghost.HT) {
partialCharge += ghost.HT / 1000f;
updateQuickslot();
if (partialCharge > 1) {
ghost.HP++;
partialCharge--;
}
} else {
partialCharge = 0;
}
return true;
} else {
defaultAction = AC_SUMMON;
}
LockedFloor lock = target.buff(LockedFloor.class);
if (charge < chargeCap && !cursed && (lock == null || lock.regenOn())) {
partialCharge += 1/5f; //500 turns to a full charge
if (partialCharge > 1){
charge++;
partialCharge--;
if (charge == chargeCap){
partialCharge = 0f;
GLog.p( Messages.get(DriedRose.class, "charged") );
}
}
} else if (cursed && Random.Int(100) == 0) {
ArrayList<Integer> spawnPoints = new ArrayList<>();
for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
int p = target.pos + PathFinder.NEIGHBOURS8[i];
if (Actor.findChar(p) == null && (Dungeon.level.passable[p] || Dungeon.level.avoid[p])) {
spawnPoints.add(p);
}
}
if (spawnPoints.size() > 0) {
Wraith.spawnAt(Random.element(spawnPoints));
Sample.INSTANCE.play(Assets.SND_CURSED);
}
}
updateQuickslot();
return true;
}
}
public CellSelector.Listener ghostDirector = new CellSelector.Listener(){
@Override
public void onSelect(Integer cell) {
if (cell == null) return;
Sample.INSTANCE.play( Assets.SND_GHOST );
if (!Dungeon.level.heroFOV[cell]
|| Actor.findChar(cell) == null
|| (Actor.findChar(cell) != Dungeon.hero && Actor.findChar(cell).alignment != Char.Alignment.ENEMY)){
ghost.yell(Messages.get(ghost, "directed_position_" + Random.IntRange(1, 5)));
ghost.aggro(null);
ghost.state = ghost.WANDERING;
ghost.defendingPos = cell;
ghost.movingToDefendPos = true;
return;
}
if (ghost.fieldOfView == null || ghost.fieldOfView.length != Dungeon.level.length()){
ghost.fieldOfView = new boolean[Dungeon.level.length()];
}
Dungeon.level.updateFieldOfView( ghost, ghost.fieldOfView );
if (Actor.findChar(cell) == Dungeon.hero){
ghost.yell(Messages.get(ghost, "directed_follow_" + Random.IntRange(1, 5)));
ghost.aggro(null);
ghost.state = ghost.WANDERING;
ghost.defendingPos = -1;
ghost.movingToDefendPos = false;
} else if (Actor.findChar(cell).alignment == Char.Alignment.ENEMY){
ghost.yell(Messages.get(ghost, "directed_attack_" + Random.IntRange(1, 5)));
ghost.aggro(Actor.findChar(cell));
ghost.setTarget(cell);
ghost.movingToDefendPos = false;
}
}
@Override
public String prompt() {
return "\"" + Messages.get(GhostHero.class, "direct_prompt") + "\"";
}
};
public static class Petal extends Item {
{
stackable = true;
dropsDownHeap = true;
image = ItemSpriteSheet.PETAL;
}
@Override
public boolean doPickUp( Hero hero ) {
DriedRose rose = hero.belongings.getItem( DriedRose.class );
if (rose == null){
GLog.w( Messages.get(this, "no_rose") );
return false;
} if ( rose.level() >= rose.levelCap ){
GLog.i( Messages.get(this, "no_room") );
hero.spendAndNext(TIME_TO_PICK_UP);
return true;
} else {
rose.upgrade();
if (rose.level() == rose.levelCap) {
GLog.p( Messages.get(this, "maxlevel") );
} else
GLog.i( Messages.get(this, "levelup") );
Sample.INSTANCE.play( Assets.SND_DEWDROP );
hero.spendAndNext(TIME_TO_PICK_UP);
return true;
}
}
}
public static class GhostHero extends NPC {
{
spriteClass = GhostSprite.class;
flying = true;
alignment = Alignment.ALLY;
intelligentAlly = true;
WANDERING = new Wandering();
state = HUNTING;
//before other mobs
actPriority = MOB_PRIO + 1;
properties.add(Property.UNDEAD);
}
private DriedRose rose = null;
public GhostHero(){
super();
}
public GhostHero(DriedRose rose){
super();
this.rose = rose;
updateRose();
HP = HT;
}
private void updateRose(){
if (rose == null) {
rose = Dungeon.hero.belongings.getItem(DriedRose.class);
}
//same dodge as the hero
defenseSkill = (Dungeon.hero.lvl+4);
if (rose == null) return;
HT = 20 + 8*rose.level();
}
private int defendingPos = -1;
private boolean movingToDefendPos = false;
public void clearDefensingPos(){
defendingPos = -1;
movingToDefendPos = false;
}
@Override
protected boolean act() {
updateRose();
if (rose == null || !rose.isEquipped(Dungeon.hero)){
damage(1, this);
}
if (!isAlive())
return true;
if (!Dungeon.hero.isAlive()){
sayHeroKilled();
sprite.die();
destroy();
return true;
}
return super.act();
}
@Override
protected Char chooseEnemy() {
Char enemy = super.chooseEnemy();
int targetPos = defendingPos != -1 ? defendingPos : Dungeon.hero.pos;
//will never attack something far from their target
if (enemy != null
&& Dungeon.level.mobs.contains(enemy)
&& (Dungeon.level.distance(enemy.pos, targetPos) <= 8)){
return enemy;
}
return null;
}
@Override
public int attackSkill(Char target) {
//same accuracy as the hero.
int acc = Dungeon.hero.lvl + 9;
if (rose != null && rose.weapon != null){
acc *= rose.weapon.accuracyFactor(this);
}
return acc;
}
@Override
protected float attackDelay() {
float delay = super.attackDelay();
if (rose != null && rose.weapon != null){
delay *= rose.weapon.speedFactor(this);
}
return delay;
}
@Override
protected boolean canAttack(Char enemy) {
return super.canAttack(enemy) || (rose != null && rose.weapon != null && rose.weapon.canReach(this, enemy.pos));
}
@Override
public int damageRoll() {
int dmg = 0;
if (rose != null && rose.weapon != null){
dmg += rose.weapon.damageRoll(this);
} else {
dmg += Random.NormalIntRange(0, 5);
}
return dmg;
}
@Override
public int attackProc(Char enemy, int damage) {
damage = super.attackProc(enemy, damage);
if (rose != null && rose.weapon != null) {
damage = rose.weapon.proc( this, enemy, damage );
}
return damage;
}
@Override
public int defenseProc(Char enemy, int damage) {
if (rose != null && rose.armor != null) {
return rose.armor.proc( enemy, this, damage );
} else {
return super.defenseProc(enemy, damage);
}
}
@Override
public void damage(int dmg, Object src) {
//TODO improve this when I have proper damage source logic
if (rose != null && rose.armor != null && rose.armor.hasGlyph(AntiMagic.class, this)
&& AntiMagic.RESISTS.contains(src.getClass())){
dmg -= AntiMagic.drRoll(rose.armor.level());
}
super.damage( dmg, src );
//for the rose status indicator
Item.updateQuickslot();
}
@Override
public float speed() {
float speed = super.speed();
if (rose != null && rose.armor != null){
speed = rose.armor.speedFactor(this, speed);
}
return speed;
}
@Override
public int defenseSkill(Char enemy) {
int defense = super.defenseSkill(enemy);
if (defense != 0 && rose != null && rose.armor != null ){
defense = Math.round(rose.armor.evasionFactor( this, defense ));
}
return defense;
}
@Override
public float stealth() {
float stealth = super.stealth();
if (rose != null && rose.armor != null){
stealth = rose.armor.stealthFactor(this, stealth);
}
return stealth;
}
@Override
public int drRoll() {
int block = 0;
if (rose != null && rose.armor != null){
block += Random.NormalIntRange( rose.armor.DRMin(), rose.armor.DRMax());
}
if (rose != null && rose.weapon != null){
block += Random.NormalIntRange( 0, rose.weapon.defenseFactor( this ));
}
return block;
}
private void setTarget(int cell) {
target = cell;
}
@Override
public boolean isImmune(Class effect) {
if (effect == Burning.class
&& rose != null
&& rose.armor != null
&& rose.armor.hasGlyph(Brimstone.class, this)){
return true;
}
return super.isImmune(effect);
}
@Override
public boolean interact() {
updateRose();
if (rose != null && !rose.talkedTo){
rose.talkedTo = true;
Game.runOnRenderThread(new Callback() {
@Override
public void call() {
GameScene.show(new WndQuest(GhostHero.this, Messages.get(GhostHero.this, "introduce") ));
}
});
return false;
} else {
return super.interact();
}
}
@Override
public void die(Object cause) {
sayDefeated();
super.die(cause);
}
@Override
public void destroy() {
updateRose();
if (rose != null) {
rose.ghost = null;
rose.charge = 0;
rose.partialCharge = 0;
rose.ghostID = -1;
rose.defaultAction = AC_SUMMON;
}
super.destroy();
}
public void sayAppeared(){
int depth = (Dungeon.depth - 1) / 5;
//only some lines are said on the first floor of a depth
int variant = Dungeon.depth % 5 == 1 ? Random.IntRange(1, 3) : Random.IntRange(1, 6);
switch(depth){
case 0:
yell( Messages.get( this, "dialogue_sewers_" + variant ));
break;
case 1:
yell( Messages.get( this, "dialogue_prison_" + variant ));
break;
case 2:
yell( Messages.get( this, "dialogue_caves_" + variant ));
break;
case 3:
yell( Messages.get( this, "dialogue_city_" + variant ));
break;
case 4: default:
yell( Messages.get( this, "dialogue_halls_" + variant ));
break;
}
if (ShatteredPixelDungeon.scene() instanceof GameScene) {
Sample.INSTANCE.play( Assets.SND_GHOST );
}
}
public void sayBoss(){
int depth = (Dungeon.depth - 1) / 5;
switch(depth){
case 0:
yell( Messages.get( this, "seen_goo_" + Random.IntRange(1, 3) ));
break;
case 1:
yell( Messages.get( this, "seen_tengu_" + Random.IntRange(1, 3) ));
break;
case 2:
yell( Messages.get( this, "seen_dm300_" + Random.IntRange(1, 3) ));
break;
case 3:
yell( Messages.get( this, "seen_king_" + Random.IntRange(1, 3) ));
break;
case 4: default:
yell( Messages.get( this, "seen_yog_" + Random.IntRange(1, 3) ));
break;
}
Sample.INSTANCE.play( Assets.SND_GHOST );
}
public void sayDefeated(){
if (BossHealthBar.isAssigned()){
yell( Messages.get( this, "defeated_by_boss_" + Random.IntRange(1, 3) ));
} else {
yell( Messages.get( this, "defeated_by_enemy_" + Random.IntRange(1, 3) ));
}
Sample.INSTANCE.play( Assets.SND_GHOST );
}
public void sayHeroKilled(){
if (Dungeon.bossLevel()){
yell( Messages.get( this, "hero_killed_boss_" + Random.IntRange(1, 3) ));
} else {
yell( Messages.get( this, "hero_killed_" + Random.IntRange(1, 3) ));
}
Sample.INSTANCE.play( Assets.SND_GHOST );
}
public void sayAnhk(){
yell( Messages.get( this, "blessed_ankh_" + Random.IntRange(1, 3) ));
Sample.INSTANCE.play( Assets.SND_GHOST );
}
private static final String DEFEND_POS = "defend_pos";
private static final String MOVING_TO_DEFEND = "moving_to_defend";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(DEFEND_POS, defendingPos);
bundle.put(MOVING_TO_DEFEND, movingToDefendPos);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
if (bundle.contains(DEFEND_POS)) defendingPos = bundle.getInt(DEFEND_POS);
movingToDefendPos = bundle.getBoolean(MOVING_TO_DEFEND);
}
{
immunities.add( ToxicGas.class );
immunities.add( CorrosiveGas.class );
immunities.add( Burning.class );
immunities.add( ScrollOfRetribution.class );
immunities.add( ScrollOfPsionicBlast.class );
immunities.add( Corruption.class );
}
private class Wandering extends Mob.Wandering {
@Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
if ( enemyInFOV && !movingToDefendPos ) {
enemySeen = true;
notice();
alerted = true;
state = HUNTING;
target = enemy.pos;
} else {
enemySeen = false;
int oldPos = pos;
target = defendingPos != -1 ? defendingPos : Dungeon.hero.pos;
//always move towards the hero when wandering
if (getCloser( target )) {
//moves 2 tiles at a time when returning to the hero
if (defendingPos == -1 && !Dungeon.level.adjacent(target, pos)){
getCloser( target );
}
spend( 1 / speed() );
if (pos == defendingPos) movingToDefendPos = false;
return moveSprite( oldPos, pos );
} else {
spend( TICK );
}
}
return true;
}
}
}
private static class WndGhostHero extends Window{
private static final int BTN_SIZE = 32;
private static final float GAP = 2;
private static final float BTN_GAP = 12;
private static final int WIDTH = 116;
private WndBlacksmith.ItemButton btnWeapon;
private WndBlacksmith.ItemButton btnArmor;
WndGhostHero(final DriedRose rose){
IconTitle titlebar = new IconTitle();
titlebar.icon( new ItemSprite(rose) );
titlebar.label( Messages.get(this, "title") );
titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar );
RenderedTextBlock message =
PixelScene.renderTextBlock(Messages.get(this, "desc", rose.ghostStrength()), 6);
message.maxWidth( WIDTH );
message.setPos(0, titlebar.bottom() + GAP);
add( message );
btnWeapon = new WndBlacksmith.ItemButton(){
@Override
protected void onClick() {
if (rose.weapon != null){
item(new WndBag.Placeholder(ItemSpriteSheet.WEAPON_HOLDER));
if (!rose.weapon.doPickUp(Dungeon.hero)){
Dungeon.level.drop( rose.weapon, Dungeon.hero.pos);
}
rose.weapon = null;
} else {
GameScene.selectItem(new WndBag.Listener() {
@Override
public void onSelect(Item item) {
if (!(item instanceof MeleeWeapon)) {
//do nothing, should only happen when window is cancelled
} else if (item.unique) {
GLog.w( Messages.get(WndGhostHero.class, "cant_unique"));
hide();
} else if (!item.isIdentified()) {
GLog.w( Messages.get(WndGhostHero.class, "cant_unidentified"));
hide();
} else if (item.cursed) {
GLog.w( Messages.get(WndGhostHero.class, "cant_cursed"));
hide();
} else if (((MeleeWeapon)item).STRReq() > rose.ghostStrength()) {
GLog.w( Messages.get(WndGhostHero.class, "cant_strength"));
hide();
} else {
if (item.isEquipped(Dungeon.hero)){
((MeleeWeapon) item).doUnequip(Dungeon.hero, false, false);
} else {
item.detach(Dungeon.hero.belongings.backpack);
}
rose.weapon = (MeleeWeapon) item;
item(rose.weapon);
}
}
}, WndBag.Mode.WEAPON, Messages.get(WndGhostHero.class, "weapon_prompt"));
}
}
};
btnWeapon.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.top() + message.height() + GAP, BTN_SIZE, BTN_SIZE );
if (rose.weapon != null) {
btnWeapon.item(rose.weapon);
} else {
btnWeapon.item(new WndBag.Placeholder(ItemSpriteSheet.WEAPON_HOLDER));
}
add( btnWeapon );
btnArmor = new WndBlacksmith.ItemButton(){
@Override
protected void onClick() {
if (rose.armor != null){
item(new WndBag.Placeholder(ItemSpriteSheet.ARMOR_HOLDER));
if (!rose.armor.doPickUp(Dungeon.hero)){
Dungeon.level.drop( rose.armor, Dungeon.hero.pos);
}
rose.armor = null;
} else {
GameScene.selectItem(new WndBag.Listener() {
@Override
public void onSelect(Item item) {
if (!(item instanceof Armor)) {
//do nothing, should only happen when window is cancelled
} else if (item.unique || ((Armor) item).checkSeal() != null) {
GLog.w( Messages.get(WndGhostHero.class, "cant_unique"));
hide();
} else if (!item.isIdentified()) {
GLog.w( Messages.get(WndGhostHero.class, "cant_unidentified"));
hide();
} else if (item.cursed) {
GLog.w( Messages.get(WndGhostHero.class, "cant_cursed"));
hide();
} else if (((Armor)item).STRReq() > rose.ghostStrength()) {
GLog.w( Messages.get(WndGhostHero.class, "cant_strength"));
hide();
} else {
if (item.isEquipped(Dungeon.hero)){
((Armor) item).doUnequip(Dungeon.hero, false, false);
} else {
item.detach(Dungeon.hero.belongings.backpack);
}
rose.armor = (Armor) item;
item(rose.armor);
}
}
}, WndBag.Mode.ARMOR, Messages.get(WndGhostHero.class, "armor_prompt"));
}
}
};
btnArmor.setRect( btnWeapon.right() + BTN_GAP, btnWeapon.top(), BTN_SIZE, BTN_SIZE );
if (rose.armor != null) {
btnArmor.item(rose.armor);
} else {
btnArmor.item(new WndBag.Placeholder(ItemSpriteSheet.ARMOR_HOLDER));
}
add( btnArmor );
resize(WIDTH, (int)(btnArmor.bottom() + GAP));
}
}
}
| 27,776 | DriedRose | java | en | java | code | {"qsc_code_num_words": 3072, "qsc_code_num_chars": 27776.0, "qsc_code_mean_word_length": 5.85253906, "qsc_code_frac_words_unique": 0.1702474, "qsc_code_frac_chars_top_2grams": 0.02402803, "qsc_code_frac_chars_top_3grams": 0.09088381, "qsc_code_frac_chars_top_4grams": 0.10278658, "qsc_code_frac_chars_dupe_5grams": 0.40169086, "qsc_code_frac_chars_dupe_6grams": 0.29801435, "qsc_code_frac_chars_dupe_7grams": 0.21413872, "qsc_code_frac_chars_dupe_8grams": 0.17297959, "qsc_code_frac_chars_dupe_9grams": 0.14739418, "qsc_code_frac_chars_dupe_10grams": 0.13237666, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00823973, "qsc_code_frac_chars_whitespace": 0.21788594, "qsc_code_size_file_byte": 27776.0, "qsc_code_num_lines": 1002.0, "qsc_code_num_chars_line_max": 118.0, "qsc_code_num_chars_line_mean": 27.72055888, "qsc_code_frac_chars_alphabet": 0.81937028, "qsc_code_frac_chars_comments": 0.05105127, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.28875, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.02496396, "qsc_code_frac_chars_long_word_length": 0.00110024, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.000998, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.06125, "qsc_codejava_score_lines_no_logic": 0.15875, "qsc_codejava_frac_words_no_modifier": 0.92307692, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 0.66666667, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
0-1-0/lightblue-0.4 | src/linux/lightblueobex_server.c | /*
* Copyright (c) 2009 Bea Lam. All rights reserved.
*
* This file is part of LightBlue.
*
* LightBlue 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 3 of the License, or
* (at your option) any later version.
*
* LightBlue is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lightblueobex_server.h"
#include "lightblueobex_main.h"
#include "structmember.h"
//#define LIGHTBLUEOBEX_SERVER_TEST
typedef struct {
PyObject_HEAD
obex_t *obex;
int sendbufsize;
PyObject *cb_error;
PyObject *cb_newrequest;
PyObject *cb_requestdone;
int notifiednewrequest;
int hasbodydata;
PyObject *fileobj;
PyObject *tempbuf;
#ifdef LIGHTBLUEOBEX_SERVER_TEST
uint32_t puttotal;
#endif
} OBEXServer;
static void
obexserver_error(OBEXServer *self, PyObject *type, PyObject *value)
{
PyObject *result;
PyObject *tmpValue;
DEBUG("%s()\n", __func__);
if (self->cb_error == NULL) { /* shouldn't happen, checked in init */
DEBUG("\tcb_error() is NULL");
return;
}
tmpValue = (value == NULL ? PyString_FromString("server error") : value);
result = PyObject_CallFunctionObjArgs(self->cb_error,
(type == NULL ? PyExc_IOError : type), value, NULL);
if (result == NULL)
DEBUG("\tfailed to call cb_error()\n");
else
Py_DECREF(result);
/* don't want exceptions to be raised */
/*PyErr_Clear();*/
DEBUG("\terror was:\n");
PyErr_Print(); /* clears the error indicator */
}
static void
obexserver_errorstr(OBEXServer *self, PyObject *exc, char *message)
{
PyObject *msgobj;
DEBUG("%s() - error with string msg\n", __func__);
msgobj = PyString_FromString(message);
obexserver_error(self, exc, msgobj);
Py_XDECREF(msgobj);
}
static void
obexserver_errorfetch(OBEXServer *self)
{
DEBUG("%s() - load from set error\n", __func__);
if (!PyErr_Occurred()) {
DEBUG("\tno error set, raise generic error\n");
obexserver_error(self, NULL, NULL);
} else {
PyObject *pType;
PyObject *pValue;
PyObject *pTraceback;
PyErr_Fetch(&pType, &pValue, &pTraceback); /* value, TB can be null */
obexserver_error(self, pType, pValue);
Py_XDECREF(pType);
Py_XDECREF(pValue);
Py_XDECREF(pTraceback);
}
}
/*
Returns new reference that must be decref'd.
*/
static PyObject*
obexserver_notifynewrequest(OBEXServer *self, obex_object_t *obj, int obex_cmd, int *respcode)
{
PyObject *resp;
PyObject *respheaders;
PyObject *tmpfileobj;
PyObject *reqheaders;
int nonhdrdata_len;
PyObject *nonhdrdata_obj;
uint8_t *nonhdrdata;
DEBUG("%s() cmd=%d\n", __func__, obex_cmd);
if (self->notifiednewrequest) {
DEBUG("\tAlready called cb_newrequest");
return NULL;
}
if (self->cb_newrequest == NULL) { /* shouldn't happen */
obexserver_errorstr(self, PyExc_IOError, "cb_newrequest is NULL");
return NULL;
}
reqheaders = lightblueobex_readheaders(self->obex, obj);
if (reqheaders == NULL) {
obexserver_errorstr(self, PyExc_IOError,
"error reading request headers");
return NULL;
}
nonhdrdata_len = OBEX_ObjectGetNonHdrData(obj, &nonhdrdata);
if (nonhdrdata_len < 0) {
obexserver_errorstr(self, PyExc_IOError,
"error reading non-header data");
return NULL;
}
nonhdrdata_obj = PyBuffer_FromMemory(nonhdrdata,
(Py_ssize_t)nonhdrdata_len);
if (nonhdrdata_obj == NULL) {
obexserver_errorstr(self, PyExc_IOError,
"error reading non-header buffer");
return NULL;
}
resp = PyObject_CallFunction(self->cb_newrequest, "iOOO",
obex_cmd, reqheaders, nonhdrdata_obj,
(self->hasbodydata ? Py_True : Py_False));
Py_DECREF(nonhdrdata_obj);
self->notifiednewrequest = 1;
if (resp == NULL) {
DEBUG("\terror calling cb_newrequest\n");
obexserver_errorfetch(self);
return NULL;
}
if ( !PyTuple_Check(resp) || PyTuple_Size(resp) < 3 ||
!PyInt_Check(PyTuple_GetItem(resp, 0)) ||
!PyDict_Check(PyTuple_GetItem(resp, 1)) ) {
obexserver_errorstr(self, PyExc_TypeError,
"callback must return (int, dict, fileobj | None) tuple");
return NULL;
}
tmpfileobj = PyTuple_GetItem(resp, 2);
if (obex_cmd == OBEX_CMD_PUT && self->hasbodydata &&
!PyObject_HasAttrString(tmpfileobj, "write")) {
obexserver_errorstr(self, PyExc_ValueError,
"specified file object does not have 'write' method for Put request");
return NULL;
}
if (obex_cmd == OBEX_CMD_GET &&
!PyObject_HasAttrString(tmpfileobj, "read")) {
obexserver_errorstr(self, PyExc_ValueError,
"specified file object does not have 'read' method for Get request");
return NULL;
}
*respcode = PyInt_AsLong(PyTuple_GetItem(resp, 0));
if (PyErr_Occurred()) {
PyErr_Clear();
obexserver_errorstr(self, PyExc_IOError,
"error reading returned response code");
return NULL;
}
Py_XDECREF(self->fileobj);
Py_INCREF(tmpfileobj);
self->fileobj = tmpfileobj;
respheaders = PyTuple_GetItem(resp, 1);
Py_INCREF(respheaders);
return respheaders;
}
static int
obexserver_setresponse(OBEXServer *self, obex_object_t *obj, int responsecode, PyObject *responseheaders)
{
DEBUG("%s()\n", __func__);
if (responseheaders != NULL) {
if (lightblueobex_addheaders(self->obex, responseheaders, obj) < 0) {
obexserver_errorstr(self, PyExc_IOError,
"error setting response headers");
OBEX_ObjectSetRsp(obj, OBEX_RSP_INTERNAL_SERVER_ERROR,
OBEX_RSP_INTERNAL_SERVER_ERROR);
return -1;
}
}
if (responsecode == OBEX_RSP_SUCCESS || responsecode == OBEX_RSP_CONTINUE) {
DEBUG("\tAccepting request...\n");
OBEX_ObjectSetRsp(obj, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS);
} else {
DEBUG("\tRefusing request (%s)...\n",
OBEX_ResponseToString(responsecode));
OBEX_ObjectSetRsp(obj, responsecode, responsecode);
}
return 1;
}
static void
obexserver_receivedrequest(OBEXServer *self, obex_object_t *obj, int obex_cmd)
{
int respcode;
PyObject *respheaders;
DEBUG("%s()\n", __func__);
// Put requests are taken care of in obexserver_streamavailable()
if (obex_cmd == OBEX_CMD_PUT && self->hasbodydata) {
#ifdef LIGHTBLUEOBEX_SERVER_TEST
obex_headerdata_t hv;
hv.bq4 = self->puttotal;
OBEX_ObjectAddHeader(self->obex, obj, OBEX_HDR_LENGTH, hv, 4, 0);
#endif
return;
}
respheaders = obexserver_notifynewrequest(self, obj, obex_cmd, &respcode);
if (respheaders == NULL) {
obexserver_setresponse(self, obj, OBEX_RSP_INTERNAL_SERVER_ERROR, NULL);
} else {
int result;
result = obexserver_setresponse(self, obj, respcode, respheaders);
/* for Get requests, indicate we want OBEX_EV_STREAMEMPTY events */
if (result >= 0 && obex_cmd == OBEX_CMD_GET &&
(respcode == OBEX_RSP_CONTINUE || respcode == OBEX_RSP_SUCCESS)) {
obex_headerdata_t hv;
hv.bs = NULL;
OBEX_ObjectAddHeader(self->obex, obj, OBEX_HDR_BODY, hv, 0,
OBEX_FL_STREAM_START);
}
}
Py_XDECREF(respheaders);
}
static void
obexserver_streamavailable(OBEXServer *self, obex_object_t *obj)
{
DEBUG("%s()\n", __func__);
/* if got OBEX_EV_STREAMAVAIL, it means the request contains body data
(and therefore is not a Put-Delete) */
self->hasbodydata = 1;
if (!self->notifiednewrequest) {
PyObject *respheaders;
int respcode;
respheaders = obexserver_notifynewrequest(self, obj, OBEX_CMD_PUT,
&respcode);
if (respheaders == NULL) {
obexserver_setresponse(self, obj, OBEX_RSP_INTERNAL_SERVER_ERROR,
NULL);
return;
}
obexserver_setresponse(self, obj, respcode, respheaders);
Py_DECREF(respheaders);
if (respcode != OBEX_RSP_CONTINUE && respcode != OBEX_RSP_SUCCESS)
return;
}
if (self->fileobj == NULL) {
obexserver_errorstr(self, PyExc_IOError, "file object is null");
return;
}
int result;
result = lightblueobex_streamtofile(self->obex, obj, self->fileobj);
if (result < 0) {
obexserver_errorstr(self, PyExc_IOError, "error reading body data or writing to file object");
OBEX_ObjectSetRsp(obj, OBEX_RSP_INTERNAL_SERVER_ERROR,
OBEX_RSP_INTERNAL_SERVER_ERROR);
}
#ifdef LIGHTBLUEOBEX_SERVER_TEST
if (result > 0)
self->puttotal += result;
#endif
}
static void
obexserver_streamempty(OBEXServer *self, obex_object_t *obj)
{
DEBUG("%s()\n", __func__);
Py_XDECREF(self->tempbuf);
self->tempbuf = lightblueobex_filetostream(self->obex, obj, self->fileobj,
self->sendbufsize);
if (self->tempbuf == NULL) {
obexserver_errorstr(self, PyExc_IOError, "error reading file object");
OBEX_ObjectSetRsp(obj, OBEX_RSP_INTERNAL_SERVER_ERROR,
OBEX_RSP_INTERNAL_SERVER_ERROR);
}
}
static void
obexserver_requestdone(OBEXServer *self, obex_object_t *obj, int obex_cmd)
{
PyObject *result;
if (self->cb_requestdone == NULL) { /* shouldn't happen */
obexserver_errorstr(self, PyExc_IOError, "cb_requestdone is NULL");
return;
}
result = PyObject_CallFunction(self->cb_requestdone, "i", obex_cmd);
if (result == NULL) {
obexserver_errorfetch(self);
} else {
Py_DECREF(result);
}
/* clean up */
Py_XDECREF(self->tempbuf);
self->tempbuf = NULL;
Py_XDECREF(self->fileobj);
self->fileobj = NULL;
}
static void
obexserver_incomingrequest(OBEXServer *self, obex_object_t *obj, int obex_cmd)
{
self->notifiednewrequest = 0;
self->hasbodydata = 0;
Py_XDECREF(self->tempbuf);
Py_XDECREF(self->fileobj);
// signal we want to stream body data
if (obex_cmd == OBEX_CMD_PUT) {
if (OBEX_ObjectReadStream(self->obex, obj, NULL) < 0) {
DEBUG("\tUnable to stream body data\n");
OBEX_ObjectSetRsp(obj, OBEX_RSP_INTERNAL_SERVER_ERROR,
OBEX_RSP_INTERNAL_SERVER_ERROR);
return;
}
}
OBEX_ObjectSetRsp(obj, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS);
#ifdef LIGHTBLUEOBEX_SERVER_TEST
self->puttotal = 0;
#endif
}
/* can this be static? */
void
obexserver_event(obex_t *handle, obex_object_t *obj, int mode, int event, int obex_cmd, int obex_rsp)
{
DEBUG("%s()\n", __func__);
DEBUG("\tEvent: %d Command: %d\n", event, obex_cmd);
OBEXServer *self = (OBEXServer *)OBEX_GetUserData(handle);
switch (event) {
case OBEX_EV_LINKERR:
case OBEX_EV_PARSEERR:
DEBUG("\tOBEX_EV_LINKERR or OBEX_EV_PARSEERR\n");
obexserver_errorstr(self, PyExc_IOError, (event == OBEX_EV_LINKERR ?
"connection error" : "parse error"));
break;
case OBEX_EV_REQHINT:
DEBUG("\tOBEX_EV_REQHINT\n");
obexserver_incomingrequest(self, obj, obex_cmd);
break;
case OBEX_EV_REQ:
DEBUG("\tOBEX_EV_REQ\n");
obexserver_receivedrequest(self, obj, obex_cmd);
break;
case OBEX_EV_STREAMAVAIL:
DEBUG("\tOBEX_EV_STREAMAVAIL\n");
obexserver_streamavailable(self, obj);
break;
case OBEX_EV_STREAMEMPTY:
DEBUG("\tOBEX_EV_STREAMEMPTY\n");
obexserver_streamempty(self, obj);
break;
case OBEX_EV_REQDONE:
DEBUG("\tOBEX_EV_REQDONE\n");
obexserver_requestdone(self, obj, obex_cmd);
break;
default:
DEBUG("\tNot handling event\n");
break;
}
}
static PyObject *
OBEXServer_process(OBEXServer *self, PyObject *args)
{
int timeout;
int result;
DEBUG("%s()\n", __func__);
if (!PyArg_ParseTuple(args, "i", &timeout))
return NULL;
result = OBEX_HandleInput(self->obex, timeout);
return PyInt_FromLong(result);
}
PyDoc_STRVAR(OBEXServer_process__doc__,
"process(timeout) -> result\n\n\
Processes and reads incoming data with the given timeout (in seconds). \
Blocks if no data is available. Returns -1 on error and 0 on timeout.");
static PyObject *
OBEXServer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
OBEXServer *self;
self = (OBEXServer *)type->tp_alloc(type, 0);
if (self != NULL) {
self->obex = NULL;
self->sendbufsize = 1024;
self->cb_error = NULL;
self->cb_newrequest = NULL;
self->cb_requestdone = NULL;
self->notifiednewrequest = 0;
self->hasbodydata = 0;
self->fileobj = NULL;
self->tempbuf = NULL;
}
return (PyObject *)self;
}
static int
OBEXServer_init(OBEXServer *self, PyObject *args)
{
int fd;
PyObject *cb_error;
PyObject *cb_newrequest;
PyObject *cb_requestdone;
int mtu = 1024; /* todo make this a keyword arg */
if (!PyArg_ParseTuple(args, "iOOO", &fd, &cb_error, &cb_newrequest,
&cb_requestdone)) {
return -1;
}
if (!PyCallable_Check(cb_error) || !PyCallable_Check(cb_newrequest) ||
!PyCallable_Check(cb_requestdone)) {
PyErr_SetString(PyExc_TypeError, "given callback is not callable");
return -1;
}
if (self->cb_error == NULL) {
Py_INCREF(cb_error);
self->cb_error = cb_error;
}
if (self->cb_newrequest == NULL) {
Py_INCREF(cb_newrequest);
self->cb_newrequest = cb_newrequest;
}
if (self->cb_requestdone == NULL) {
Py_INCREF(cb_requestdone);
self->cb_requestdone = cb_requestdone;
}
if (self->obex == NULL) {
self->obex = OBEX_Init(OBEX_TRANS_FD, obexserver_event, 0);
if (self->obex == NULL) {
PyErr_SetString(PyExc_IOError, "error creating OBEX object");
return -1;
}
if (FdOBEX_TransportSetup(self->obex, fd, fd, mtu) < 0) {
PyErr_SetString(PyExc_IOError, "error initialising transport");
return -1;
}
}
OBEX_SetUserData(self->obex, self);
OBEX_SetTransportMTU(self->obex, OBEX_MAXIMUM_MTU, OBEX_MAXIMUM_MTU);
return 0;
}
static void
OBEXServer_dealloc(OBEXServer *self)
{
if (self->obex)
OBEX_Cleanup(self->obex);
Py_XDECREF(self->fileobj);
Py_XDECREF(self->tempbuf);
self->ob_type->tp_free((PyObject *)self);
}
static PyMemberDef OBEXServer_members[] = {
{NULL} /* Sentinel */
};
static PyMethodDef OBEXServer_methods[] = {
{ "process", (PyCFunction)OBEXServer_process, METH_VARARGS,
OBEXServer_process__doc__,
},
{NULL} /* Sentinel */
};
static PyTypeObject OBEXServerType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"obexserver.OBEXServer", /*tp_name*/
sizeof(OBEXServer), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)OBEXServer_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
"An OBEX server class.", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
OBEXServer_methods, /* tp_methods */
OBEXServer_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)OBEXServer_init, /* tp_init */
0, /* tp_alloc */
OBEXServer_new, /* tp_new */
};
PyTypeObject *lightblueobex_getservertype(void)
{
return &OBEXServerType;
}
| 17,510 | lightblueobex_server | c | en | c | code | {"qsc_code_num_words": 1920, "qsc_code_num_chars": 17510.0, "qsc_code_mean_word_length": 5.284375, "qsc_code_frac_words_unique": 0.2015625, "qsc_code_frac_chars_top_2grams": 0.00827912, "qsc_code_frac_chars_top_3grams": 0.03035679, "qsc_code_frac_chars_top_4grams": 0.03725606, "qsc_code_frac_chars_dupe_5grams": 0.29105066, "qsc_code_frac_chars_dupe_6grams": 0.23358959, "qsc_code_frac_chars_dupe_7grams": 0.19485512, "qsc_code_frac_chars_dupe_8grams": 0.16597674, "qsc_code_frac_chars_dupe_9grams": 0.12970629, "qsc_code_frac_chars_dupe_10grams": 0.10191208, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00636639, "qsc_code_frac_chars_whitespace": 0.28235294, "qsc_code_size_file_byte": 17510.0, "qsc_code_num_lines": 585.0, "qsc_code_num_chars_line_max": 106.0, "qsc_code_num_chars_line_mean": 29.93162393, "qsc_code_frac_chars_alphabet": 0.80105045, "qsc_code_frac_chars_comments": 0.11250714, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.34763948, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.08134372, "qsc_code_frac_chars_long_word_length": 0.00572752, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0017094, "qsc_code_frac_lines_assert": 0.0, "qsc_codec_frac_lines_func_ratio": 0.04077253, "qsc_codec_cate_bitsstdc": 0.0, "qsc_codec_nums_lines_main": 0, "qsc_codec_frac_lines_goto": 0.0, "qsc_codec_cate_var_zero": 0.0, "qsc_codec_score_lines_no_logic": 0.11587983, "qsc_codec_frac_lines_print": 0.0, "qsc_codec_frac_lines_preprocessor_directives": 0.03004292} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codec_frac_lines_func_ratio": 0, "qsc_codec_nums_lines_main": 0, "qsc_codec_score_lines_no_logic": 0, "qsc_codec_frac_lines_preprocessor_directives": 0, "qsc_codec_frac_lines_print": 0} |
0-1-0/lightblue-0.4 | src/linux/__init__.py | # Copyright (c) 2009 Bea Lam. All rights reserved.
#
# This file is part of LightBlue.
#
# LightBlue 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 3 of the License, or
# (at your option) any later version.
#
# LightBlue is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
"LightBlue - a simple bluetooth library."
# Docstrings for attributes in this module.
_docstrings = {
"finddevices":
"""
Performs a device discovery and returns the found devices as a list of
(address, name, class-of-device) tuples. Raises BluetoothError if an error
occurs.
Arguments:
- getnames=True: True if device names should be retrieved during
discovery. If false, None will be returned instead of the device
name.
- length=10: the number of seconds to spend discovering devices
(this argument has no effect on Python for Series 60)
Do not invoke a new discovery before a previous discovery has finished.
Also, to minimise interference with other wireless and bluetooth traffic,
and to conserve battery power on the local device, discoveries should not
be invoked too frequently (an interval of at least 20 seconds is
recommended).
""",
"findservices":
"""
Performs a service discovery and returns the found services as a list of
(device-address, service-port, service-name) tuples. Raises BluetoothError
if an error occurs.
Arguments:
- addr=None: a device address, to search only for services on a
specific device
- name=None: a service name string, to search only for a service with a
specific name
- servicetype=None: can be RFCOMM or OBEX to search only for RFCOMM or
OBEX-type services. (OBEX services are not returned from an RFCOMM
search)
If more than one criteria is specified, this returns services that match
all criteria.
Currently the Python for Series 60 implementation will only find RFCOMM and
OBEX services.
""",
"finddevicename":
"""
Returns the name of the device with the given bluetooth address.
finddevicename(gethostaddr()) returns the local device name.
Arguments:
- address: the address of the device to look up
- usecache=True: if True, the device name will be fetched from a local
cache if possible. If False, or if the device name is not in the
cache, the remote device will be contacted to request its name.
Raise BluetoothError if the name cannot be retrieved.
""",
"gethostaddr":
"""
Returns the address of the local bluetooth device.
Raise BluetoothError if the local device is not available.
""",
"gethostclass":
"""
Returns the class of device of the local bluetooth device.
These values indicate the device's major services and the type of the
device (e.g. mobile phone, laptop, etc.). If you google for
"assigned numbers bluetooth baseband" you might find some documents
that discuss how to extract this information from the class of device.
Raise BluetoothError if the local device is not available.
""",
"socket":
"""
socket(proto=RFCOMM) -> socket object
Returns a new socket object.
Arguments:
- proto=RFCOMM: the type of socket to be created - either L2CAP or
RFCOMM.
Note that L2CAP sockets are not available on Python For Series 60, and
only L2CAP client sockets are supported on Mac OS X and Linux (i.e. you can
connect() the socket but not bind(), accept(), etc.).
""",
"advertise":
"""
Starts advertising a service with the given name, using the given server
socket. Raises BluetoothError if the service cannot be advertised.
Arguments:
- name: name of the service to be advertised
- sock: the socket object that will serve this service. The socket must
be already bound to a channel. If a RFCOMM service is being
advertised, the socket should also be listening.
- servicetype: the type of service to advertise - either RFCOMM or
OBEX. (L2CAP services are not currently supported.)
(If the servicetype is RFCOMM, the service will be advertised with the
Serial Port Profile; if the servicetype is OBEX, the service will be
advertised with the OBEX Object Push Profile.)
""",
"stopadvertise":
"""
Stops advertising the service on the given socket. Raises BluetoothError if
no service is advertised on the socket.
This will error if the given socket is already closed.
""",
"selectdevice":
"""
Displays a GUI which allows the end user to select a device from a list of
discovered devices.
Returns the selected device as an (address, name, class-of-device) tuple.
Returns None if the selection was cancelled.
(On Python For Series 60, the device selection will fail if there are any
open bluetooth connections.)
""",
"selectservice":
"""
Displays a GUI which allows the end user to select a service from a list of
discovered devices and their services.
Returns the selected service as a (device-address, service-port, service-
name) tuple. Returns None if the selection was cancelled.
(On Python For Series 60, the device selection will fail if there are any
open bluetooth connections.)
Currently the Python for Series 60 implementation will only find RFCOMM and
OBEX services.
"""
}
# import implementation modules
from _lightblue import *
from _lightbluecommon import *
import obex # plus submodule
# set docstrings
import _lightblue
localattrs = locals()
for attr in _lightblue.__all__:
try:
localattrs[attr].__doc__ = _docstrings[attr]
except KeyError:
pass
del attr, localattrs
| 6,362 | __init__ | py | en | python | code | {"qsc_code_num_words": 877, "qsc_code_num_chars": 6362.0, "qsc_code_mean_word_length": 4.99657925, "qsc_code_frac_words_unique": 0.32041049, "qsc_code_frac_chars_top_2grams": 0.01141031, "qsc_code_frac_chars_top_3grams": 0.02053857, "qsc_code_frac_chars_top_4grams": 0.02327704, "qsc_code_frac_chars_dupe_5grams": 0.26289366, "qsc_code_frac_chars_dupe_6grams": 0.21497033, "qsc_code_frac_chars_dupe_7grams": 0.17343679, "qsc_code_frac_chars_dupe_8grams": 0.15837517, "qsc_code_frac_chars_dupe_9grams": 0.13555454, "qsc_code_frac_chars_dupe_10grams": 0.13555454, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00527649, "qsc_code_frac_chars_whitespace": 0.25526564, "qsc_code_size_file_byte": 6362.0, "qsc_code_num_lines": 172.0, "qsc_code_num_chars_line_max": 81.0, "qsc_code_num_chars_line_mean": 36.98837209, "qsc_code_frac_chars_alphabet": 0.91958632, "qsc_code_frac_chars_comments": 0.12951902, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.27191413, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codepython_cate_ast": 1.0, "qsc_codepython_frac_lines_func_ratio": 0.0, "qsc_codepython_cate_var_zero": false, "qsc_codepython_frac_lines_pass": 0.03030303, "qsc_codepython_frac_lines_import": 0.12121212, "qsc_codepython_frac_lines_simplefunc": 0.0, "qsc_codepython_score_lines_no_logic": 0.12121212, "qsc_codepython_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codepython_cate_ast": 0, "qsc_codepython_frac_lines_func_ratio": 0, "qsc_codepython_cate_var_zero": 0, "qsc_codepython_frac_lines_pass": 0, "qsc_codepython_frac_lines_import": 0, "qsc_codepython_frac_lines_simplefunc": 0, "qsc_codepython_score_lines_no_logic": 0, "qsc_codepython_frac_lines_print": 0} |
0-1-0/lightblue-0.4 | src/linux/_discoveryui.py | # Copyright (c) 2009 Bea Lam. All rights reserved.
#
# This file is part of LightBlue.
#
# LightBlue 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 3 of the License, or
# (at your option) any later version.
#
# LightBlue is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
try:
from Tkinter import *
except ImportError, e:
raise ImportError("Error loading GUIs for selectdevice() and selectservice(), Tkinter not found: " + str(e))
# Provides services for controlling a listbox, tracking selections, etc.
class ListboxController(object):
def __init__(self, listbox, cb_chosen):
"""
Arguments:
- cb_chosen: called when a listbox item is chosen -- i.e. when
an item is double-clicked or the <Return> key is pressed while
an item is selected.
"""
self.setlistbox(listbox)
self.cb_chosen = cb_chosen
self.__alarmIDs = {}
def setlistbox(self, listbox):
self.listbox = listbox
self.listbox.bind("<Double-Button-1>", lambda evt: self._chosen())
self.listbox.bind("<Return>", lambda evt: lambda evt: self._chosen())
# adds an item to the list
def add(self, *items):
for item in items:
self.listbox.insert(END, item)
# clears items in listbox & refreshes UI
def clear(self):
self.listbox.delete(0, END)
# selects an item in the list.
# pass index=None to deselect.
def select(self, index):
self._deselect()
if index is not None:
self.listbox.selection_set(index)
self.listbox.focus()
def _deselect(self):
selected = self.selectedindex()
if selected != -1:
self.listbox.selection_clear(selected)
def selectedindex(self):
sel = self.listbox.curselection()
if len(sel) > 0:
return int(sel[0])
return -1
# starts polling the listbox for a user selection and calls cb_selected
# when an item is selected.
def track(self, cb_selected, interval=100):
self._track(interval, -1, cb_selected)
def _track(self, interval, lastindex, callback):
index = self.selectedindex()
if index != -1 and index != lastindex:
callback(index)
# recursively keep tracking
self.__alarmIDs[id(self.listbox)] = self.listbox.after(
interval, self._track, interval, index, callback)
def stoptracking(self):
for x in self.__alarmIDs.values():
self.listbox.after_cancel(x)
def focus(self):
self.listbox.focus()
def update(self):
self.listbox.update()
# called when a selection has been chosen (i.e. pressed return / dbl-click)
def _chosen(self):
index = self.selectedindex()
if index != -1:
self.cb_chosen(index)
# A frame which contains a listbox and has a title above the listbox.
class StandardListboxFrame(Frame):
def __init__(self, parent, title, boxwidth=28):
Frame.__init__(self, parent)
self.pack()
self.buildUI(parent, title, boxwidth)
def buildUI(self, parent, title, boxwidth):
bigframe = Frame(parent)
bigframe.pack(side=LEFT, fill=BOTH, expand=1)
self.titlelabel = Label(bigframe, text=title)
self.titlelabel.pack(side=TOP)
mainframe = Frame(bigframe, bd=1, relief=SUNKEN)
mainframe.pack(side=BOTTOM, fill=BOTH, expand=1)
scrollbar = Scrollbar(mainframe)
scrollbar.pack(side=RIGHT, fill=Y)
self.listbox = Listbox(mainframe, bd=1, exportselection=0)
self.listbox.pack(fill=BOTH, expand=1)
self.listbox.config(background="white", width=boxwidth)
# attach listbox to scrollbar
self.listbox.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=self.listbox.yview)
def settitle(self, title):
self.titlelabel.config(text=title)
class StatusBar(object):
def __init__(self, parent, side=TOP, text=""):
self.label = Label(parent, text=text, bd=0, pady=8)
self.label.pack(side=side, fill=BOTH, expand=1)
def settext(self, text):
self.label.config(text=text)
# makes UI with top pane, status bar below top pane, and bottom pane.
# Probably should use a grid geometry manager instead, might be easier.
class LayoutFrame(Frame):
def __init__(self, parent):
Frame.__init__(self, parent, padx=10, pady=5) # inner padding
self.topframe = Frame(self)
self.topframe.pack(side=TOP, fill=BOTH, expand=1)
self.statusbar = StatusBar(self)
self.lineframe = Frame(self, height=1, bg="#999999")
self.lineframe.pack(side=TOP, fill=BOTH, expand=1)
self.bottomframe = Frame(self, pady=5)
self.bottomframe.pack(side=BOTTOM, fill=BOTH, expand=1)
# Abstract class for controlling and tracking selections for a listbox.
class ItemSelectionController(object):
def __init__(self, listbox, cb_chosen):
self.cb_chosen = cb_chosen
self._controller = ListboxController(listbox, self._chosen)
self._closed = False
def getselection(self):
index = self._controller.selectedindex()
if index != -1:
return self._getitem(index)
return None
# set callback=None to switch off tracking
def trackselections(self, callback, interval=100):
if callback is not None:
self.cb_selected = callback
self._controller.track(self._selected, interval)
else:
self._controller.stoptracking()
def close(self):
self._controller.stoptracking()
self._closed = True
def closed(self):
return self._closed
# called when an item is chosen (e.g. dbl-clicked, not just selected)
def _chosen(self, index):
if self.cb_chosen:
self.cb_chosen(self._getitem(index))
def _selected(self, index):
if self.cb_selected:
self.cb_selected(self._getitem(index))
# move focus to this listbox
self._controller.focus()
def getitemcount(self):
raise NotImplementedError
def _getitem(self, index):
raise NotImplementedError
class DeviceSelectionController(ItemSelectionController):
# keep cache across instances (and across different sessions)
_cache = []
def __init__(self, listbox, cb_chosen):
super(DeviceSelectionController, self).__init__(listbox, cb_chosen)
self._discoverer = None
self.__items = []
self._loadcache()
def close(self):
self._stopdiscovery()
DeviceSelectionController._cache = self.__items[:]
super(DeviceSelectionController, self).close()
def refreshdevices(self):
self.__items = []
self._controller.clear()
self._controller.update()
self._stopdiscovery()
self._discoverer = _DeviceDiscoverer(self._founddevice, None)
self._discoverer.find_devices(duration=10)
#self._test("device", 0, 5)
def _additem(self, deviceinfo):
self.__items.append(deviceinfo)
self._controller.add(deviceinfo[1]) # add name
def getitemcount(self):
return len(self.__items)
def _getitem(self, index):
return self.__items[index]
def _founddevice(self, address, deviceclass, name):
self._additem((address, name, deviceclass))
# push updates to ensure names are progressively added to the display
self._controller.listbox.update()
def _loadcache(self):
for item in DeviceSelectionController._cache:
self._additem(item)
def _stopdiscovery(self):
if self._discoverer is not None:
self._discoverer.cancel_inquiry()
def _test(self, desc, n, max):
import threading
if n < max:
dummy = ("00:00:00:00:00:"+str(n), "Device-" + str(n), 0)
self._additem(dummy)
threading.Timer(1.0, self._test, [desc, n+1, max]).start()
class ServiceSelectionController(ItemSelectionController):
def __init__(self, listbox, cb_chosen):
super(ServiceSelectionController, self).__init__(listbox, cb_chosen)
self.__items = []
# keep cache for each session (i.e. each time window is opened)
self._sessioncache = {}
def _additem(self, service):
self.__items.append(service)
self._controller.add(self._getservicedesc(service))
def getitemcount(self):
return len(self.__items)
# show services for given device address
# pass address=None to clear display
def showservices(self, address):
self.__items = []
self._controller.clear()
if address is None: return
services = self._sessioncache.get(address)
if not services:
import lightblue
services = lightblue.findservices(address)
#services = [("", 1, "one"), ("", 2, "two"), ("", 3, "three")]
self._sessioncache[address] = services
if len(services) > 0:
for service in services:
self._additem(service)
def _getitem(self, index):
return self.__items[index]
def _getservicedesc(self, service):
address, port, name = service
return "(%s) %s" % (str(port), name)
class DeviceSelector(Frame):
title = "Select Bluetooth device"
def __init__(self, parent=None):
Frame.__init__(self, parent)
self.pack()
self._buildUI()
self._selection = None
self._closed = False
self.master.bind("<Escape>", lambda evt: self._clickedcancel())
def _buildUI(self):
mainframe = LayoutFrame(self)
mainframe.pack()
self._statusbar = mainframe.statusbar
self._buildlistdisplay(mainframe.topframe)
self._buildbuttons(mainframe.bottomframe)
def _buildlistdisplay(self, parent):
self.devicesframe = StandardListboxFrame(parent, "Devices",
boxwidth=38)
self.devicesframe.pack(side=LEFT, fill=BOTH, expand=1)
self._devicemanager = DeviceSelectionController(
self.devicesframe.listbox, self._chosedevice)
def _buildbuttons(self, parent):
self._searchbutton = Button(parent, text="Search for devices",
command=self._clickedsearch)
self._searchbutton.pack(side=LEFT)
self._selectbutton = Button(parent, text="Select",
command=self._clickedselect)
self._selectbutton.pack(side=RIGHT)
self._selectbutton.config(state=DISABLED)
self._cancelbutton = Button(parent, text="Cancel",
command=self._clickedcancel)
self._cancelbutton.pack(side=RIGHT)
def run(self):
try:
self._trackselections(True)
# run gui event loop
self.mainloop()
except Exception, e:
print "Warning: error during device selection:", e
def _trackselections(self, track):
if track:
self._devicemanager.trackselections(self._selecteddevice)
else:
self._devicemanager.trackselections(None)
def getresult(self):
return self._selection
def _selecteddevice(self, device):
self._selectbutton.config(state=NORMAL)
def _chosedevice(self, device):
self._clickedselect()
def _clickedsearch(self):
self._statusbar.settext("Searching for nearby devices...")
self._searchbutton.config(state=DISABLED)
self._selectbutton.config(state=DISABLED)
self.update()
self._devicemanager.refreshdevices()
if not self._closed:
self._statusbar.settext(
"Found %d devices." % self._devicemanager.getitemcount())
self._searchbutton.config(state=NORMAL)
def _clickedcancel(self):
self._quit()
def _clickedselect(self):
self._selection = self._devicemanager.getselection()
self._quit()
def _quit(self):
self._closed = True
self._devicemanager.close()
#Frame.quit(self) # doesn't close the window
self.master.destroy()
class ServiceSelector(DeviceSelector):
title = "Select Bluetooth service"
def _buildlistdisplay(self, parent):
self.devicesframe = StandardListboxFrame(parent, "Devices")
self.devicesframe.pack(side=LEFT, fill=BOTH, expand=1)
self._devicemanager = DeviceSelectionController(
self.devicesframe.listbox, self._pickeddevice)
# hack some space in between the 2 lists
spacerframe = Frame(parent, width=10)
spacerframe.pack(side=LEFT, fill=BOTH, expand=1)
self.servicesframe = StandardListboxFrame(parent, "Services")
self.servicesframe.pack(side=LEFT, fill=BOTH, expand=1)
self._servicemanager = ServiceSelectionController(
self.servicesframe.listbox, self._choseservice)
def _trackselections(self, track):
if track:
self._devicemanager.trackselections(self._pickeddevice)
self._servicemanager.trackselections(self._selectedservice)
else:
self._devicemanager.trackselections(None)
self._servicemanager.trackselections(None)
def _clearservices(self):
self.servicesframe.settitle("Services")
self._servicemanager.showservices(None) # clear services list
# called when a device is selected, or chosen
def _pickeddevice(self, deviceinfo):
self._clearservices()
self._statusbar.settext("Finding services for %s..." % deviceinfo[1])
self._selectbutton.config(state=DISABLED)
self._searchbutton.config(state=DISABLED)
self.update()
self._servicemanager.showservices(deviceinfo[0])
if not self._closed: # user might have clicked 'cancel'
self.servicesframe.settitle("%s's services" % deviceinfo[1])
self._statusbar.settext("Found %d services for %s." % (
self._servicemanager.getitemcount(),
deviceinfo[1]))
self._searchbutton.config(state=NORMAL)
def _selectedservice(self, service):
self._selectbutton.config(state=NORMAL)
def _choseservice(self, service):
self._clickedselect()
def _clickedsearch(self):
self._clearservices()
self._trackselections(False) # don't track selections while searching
# do the search
DeviceSelector._clickedsearch(self)
# re-enable selection tracking
if not self._closed:
self._trackselections(True)
def _clickedselect(self):
self._selection = self._servicemanager.getselection()
self._quit()
def _quit(self):
self._closed = True
self._devicemanager.close()
self._servicemanager.close()
self.master.destroy()
# -----------------------------------
import select
import bluetooth
class _DeviceDiscoverer(bluetooth.DeviceDiscoverer):
def __init__(self, cb_found, cb_complete):
bluetooth.DeviceDiscoverer.__init__(self) # old-style superclass
self.cb_found = cb_found
self.cb_complete = cb_complete
def find_devices(self, lookup_names=True, duration=8, flush_cache=True):
bluetooth.DeviceDiscoverer.find_devices(self, lookup_names, duration, flush_cache)
# process until inquiry is complete
self._done = False
self._cancelled = False
while not self._done and not self._cancelled:
#print "Processed"
readfiles = [self,]
rfds = select.select(readfiles, [], [])[0]
if self in rfds:
self.process_event()
# cancel_inquiry() doesn't like getting stopped in the middle of
# process_event() maybe? so just use flag instead.
if self._cancelled:
bluetooth.DeviceDiscoverer.cancel_inquiry(self)
def cancel_inquiry(self):
self._cancelled = True
def device_discovered(self, address, deviceclass, name):
#print "device_discovered", address, deviceclass, name
if self.cb_found:
self.cb_found(address, deviceclass, name)
def inquiry_complete(self):
#print "inquiry_complete"
self._done = True
if self.cb_complete:
self.cb_complete()
# -----------------------------------
# Centres a tkinter window
def centrewindow(win):
win.update_idletasks()
xmax = win.winfo_screenwidth()
ymax = win.winfo_screenheight()
x0 = (xmax - win.winfo_reqwidth()) / 2
y0 = (ymax - win.winfo_reqheight()) / 2
win.geometry("+%d+%d" % (x0, y0))
def setupwin(rootwin, title):
# set window title
rootwin.title(title)
# place window at centre
rootwin.after_idle(centrewindow, rootwin)
rootwin.update()
# -----------------------------------
def selectdevice():
rootwin = Tk()
selector = DeviceSelector(rootwin)
setupwin(rootwin, DeviceSelector.title)
selector.run()
return selector.getresult()
def selectservice():
rootwin = Tk()
selector = ServiceSelector(rootwin)
setupwin(rootwin, ServiceSelector.title)
selector.run()
return selector.getresult()
if __name__ == "__main__":
print selectservice() | 17,786 | _discoveryui | py | en | python | code | {"qsc_code_num_words": 1967, "qsc_code_num_chars": 17786.0, "qsc_code_mean_word_length": 5.65378749, "qsc_code_frac_words_unique": 0.21301474, "qsc_code_frac_chars_top_2grams": 0.02373887, "qsc_code_frac_chars_top_3grams": 0.01384768, "qsc_code_frac_chars_top_4grams": 0.0148368, "qsc_code_frac_chars_dupe_5grams": 0.21967449, "qsc_code_frac_chars_dupe_6grams": 0.1823577, "qsc_code_frac_chars_dupe_7grams": 0.11015196, "qsc_code_frac_chars_dupe_8grams": 0.08695261, "qsc_code_frac_chars_dupe_9grams": 0.06636094, "qsc_code_frac_chars_dupe_10grams": 0.04478015, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00676488, "qsc_code_frac_chars_whitespace": 0.25199595, "qsc_code_size_file_byte": 17786.0, "qsc_code_num_lines": 563.0, "qsc_code_num_chars_line_max": 113.0, "qsc_code_num_chars_line_mean": 31.59147425, "qsc_code_frac_chars_alphabet": 0.82914913, "qsc_code_frac_chars_comments": 0.14612617, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.27977839, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.02845256, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codepython_cate_ast": 0.0, "qsc_codepython_frac_lines_func_ratio": null, "qsc_codepython_cate_var_zero": null, "qsc_codepython_frac_lines_pass": 0.0, "qsc_codepython_frac_lines_import": 0.01939058, "qsc_codepython_frac_lines_simplefunc": null, "qsc_codepython_score_lines_no_logic": null, "qsc_codepython_frac_lines_print": 0.00554017} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codepython_cate_ast": 1, "qsc_codepython_frac_lines_func_ratio": 0, "qsc_codepython_cate_var_zero": 0, "qsc_codepython_frac_lines_pass": 0, "qsc_codepython_frac_lines_import": 0, "qsc_codepython_frac_lines_simplefunc": 0, "qsc_codepython_score_lines_no_logic": 0, "qsc_codepython_frac_lines_print": 0} |
0-1-0/lightblue-0.4 | src/linux/_lightbluecommon.py | # Copyright (c) 2009 Bea Lam. All rights reserved.
#
# This file is part of LightBlue.
#
# LightBlue 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 3 of the License, or
# (at your option) any later version.
#
# LightBlue is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
# Defines attributes with common implementations across the different
# platforms.
# public attributes
__all__ = ("L2CAP", "RFCOMM", "OBEX", "BluetoothError", "splitclass")
# Protocol/service class types, used for sockets and advertising services
L2CAP, RFCOMM, OBEX = (10, 11, 12)
class BluetoothError(IOError):
"""
Generic exception raised for Bluetooth errors. This is not raised for
socket-related errors; socket objects raise the socket.error and
socket.timeout exceptions from the standard library socket module.
Note that error codes are currently platform-independent. In particular,
the Mac OS X implementation returns IOReturn error values from the IOKit
framework, and OBEXError codes from <IOBluetooth/OBEX.h> for OBEX operations.
"""
pass
def splitclass(classofdevice):
"""
Splits the given class of device to return a 3-item tuple with the
major service class, major device class and minor device class values.
These values indicate the device's major services and the type of the
device (e.g. mobile phone, laptop, etc.). If you google for
"assigned numbers bluetooth baseband" you might find some documents
that discuss how to extract this information from the class of device.
Example:
>>> splitclass(1057036)
(129, 1, 3)
>>>
"""
if not isinstance(classofdevice, int):
try:
classofdevice = int(classofdevice)
except (TypeError, ValueError):
raise TypeError("Given device class '%s' cannot be split" % \
str(classofdevice))
data = classofdevice >> 2 # skip over the 2 "format" bits
service = data >> 11
major = (data >> 6) & 0x1F
minor = data & 0x3F
return (service, major, minor)
_validbtaddr = None
def _isbtaddr(address):
"""
Returns whether the given address is a valid bluetooth address.
For example, "00:0e:6d:7b:a2:0a" is a valid address.
Returns False if the argument is None or is not a string.
"""
# Define validity regex. Accept either ":" or "-" as separators.
global _validbtaddr
if _validbtaddr is None:
import re
_validbtaddr = re.compile("((\d|[a-f]){2}(:|-)){5}(\d|[a-f]){2}",
re.IGNORECASE)
import types
if not isinstance(address, types.StringTypes):
return False
return _validbtaddr.match(address) is not None
# --------- other attributes ---------
def _joinclass(codtuple):
"""
The opposite of splitclass(). Joins a (service, major, minor) class-of-
device tuple into a whole class of device value.
"""
if not isinstance(codtuple, tuple):
raise TypeError("argument must be tuple, was %s" % type(codtuple))
if len(codtuple) != 3:
raise ValueError("tuple must have 3 items, has %d" % len(codtuple))
serviceclass = codtuple[0] << 2 << 11
majorclass = codtuple[1] << 2 << 6
minorclass = codtuple[2] << 2
return (serviceclass | majorclass | minorclass)
# Docstrings for socket objects.
# Based on std lib socket docs.
_socketdocs = {
"accept":
"""
accept() -> (socket object, address info)
Wait for an incoming connection. Return a new socket representing the
connection, and the address of the client. For RFCOMM sockets, the address
info is a pair (hostaddr, channel).
The socket must be bound and listening before calling this method.
""",
"bind":
"""
bind(address)
Bind the socket to a local address. For RFCOMM sockets, the address is a
pair (host, channel); the host must refer to the local host.
A port value of 0 binds the socket to a dynamically assigned port.
(Note that on Mac OS X, the port value must always be 0.)
The socket must not already be bound.
""",
"close":
"""
close()
Close the socket. It cannot be used after this call.
""",
"connect":
"""
connect(address)
Connect the socket to a remote address. The address should be a
(host, channel) pair for RFCOMM sockets, and a (host, PSM) pair for L2CAP
sockets.
The socket must not be already connected.
""",
"connect_ex":
"""
connect_ex(address) -> errno
This is like connect(address), but returns an error code instead of raising
an exception when an error occurs.
""",
"dup":
"""
dup() -> socket object
Returns a new socket object connected to the same system resource.
""",
"fileno":
"""
fileno() -> integer
Return the integer file descriptor of the socket.
Raises NotImplementedError on Mac OS X and Python For Series 60.
""",
"getpeername":
"""
getpeername() -> address info
Return the address of the remote endpoint. The address info is a
(host, channel) pair for RFCOMM sockets, and a (host, PSM) pair for L2CAP
sockets.
If the socket has not been connected, socket.error will be raised.
""",
"getsockname":
"""
getsockname() -> address info
Return the address of the local endpoint. The address info is a
(host, channel) pair for RFCOMM sockets, and a (host, PSM) pair for L2CAP
sockets.
If the socket has not been connected nor bound, this returns the tuple
("00:00:00:00:00:00", 0).
""",
"getsockopt":
"""
getsockopt(level, option[, bufsize]) -> value
Get a socket option. See the Unix manual for level and option.
If a nonzero buffersize argument is given, the return value is a
string of that length; otherwise it is an integer.
Currently support for socket options are platform independent -- i.e.
depends on the underlying Series 60 or BlueZ socket options support.
The Mac OS X implementation currently does not support any options at
all and automatically raises socket.error.
""",
"gettimeout":
"""
gettimeout() -> timeout
Returns the timeout in floating seconds associated with socket
operations. A timeout of None indicates that timeouts on socket
operations are disabled.
Currently not supported on Python For Series 60 implementation, which
will always return None.
""",
"listen":
"""
listen(backlog)
Enable a server to accept connections. The backlog argument must be at
least 1; it specifies the number of unaccepted connection that the system
will allow before refusing new connections.
The socket must not be already listening.
Currently not implemented on Mac OS X.
""",
"makefile":
"""
makefile([mode[, bufsize]]) -> file object
Returns a regular file object corresponding to the socket. The mode
and bufsize arguments are as for the built-in open() function.
""",
"recv":
"""
recv(bufsize[, flags]) -> data
Receive up to bufsize bytes from the socket. For the optional flags
argument, see the Unix manual. When no data is available, block until
at least one byte is available or until the remote end is closed. When
the remote end is closed and all data is read, return the empty string.
Currently the flags argument has no effect on Mac OS X.
""",
"recvfrom":
"""
recvfrom(bufsize[, flags]) -> (data, address info)
Like recv(buffersize, flags) but also return the sender's address info.
""",
"send":
"""
send(data[, flags]) -> count
Send a data string to the socket. For the optional flags
argument, see the Unix manual. Return the number of bytes
sent.
The socket must be connected to a remote socket.
Currently the flags argument has no effect on Mac OS X.
""",
"sendall":
"""
sendall(data[, flags])
Send a data string to the socket. For the optional flags
argument, see the Unix manual. This calls send() repeatedly
until all data is sent. If an error occurs, it's impossible
to tell how much data has been sent.
""",
"sendto":
"""
sendto(data[, flags], address) -> count
Like send(data, flags) but allows specifying the destination address.
For RFCOMM sockets, the address is a pair (hostaddr, channel).
""",
"setblocking":
"""
setblocking(flag)
Set the socket to blocking (flag is true) or non-blocking (false).
setblocking(True) is equivalent to settimeout(None);
setblocking(False) is equivalent to settimeout(0.0).
Initially a socket is in blocking mode. In non-blocking mode, if a
socket operation cannot be performed immediately, socket.error is raised.
The underlying implementation on Python for Series 60 only supports
non-blocking mode for send() and recv(), and ignores it for connect() and
accept().
""",
"setsockopt":
"""
setsockopt(level, option, value)
Set a socket option. See the Unix manual for level and option.
The value argument can either be an integer or a string.
Currently support for socket options are platform independent -- i.e.
depends on the underlying Series 60 or BlueZ socket options support.
The Mac OS X implementation currently does not support any options at
all and automatically raise socket.error.
""",
"settimeout":
"""
settimeout(timeout)
Set a timeout on socket operations. 'timeout' can be a float,
giving in seconds, or None. Setting a timeout of None disables
the timeout feature and is equivalent to setblocking(1).
Setting a timeout of zero is the same as setblocking(0).
If a timeout is set, the connect, accept, send and receive operations will
raise socket.timeout if a timeout occurs.
Raises NotImplementedError on Python For Series 60.
""",
"shutdown":
"""
shutdown(how)
Shut down the reading side of the socket (flag == socket.SHUT_RD), the
writing side of the socket (flag == socket.SHUT_WR), or both ends
(flag == socket.SHUT_RDWR).
"""
}
| 10,831 | _lightbluecommon | py | en | python | code | {"qsc_code_num_words": 1463, "qsc_code_num_chars": 10831.0, "qsc_code_mean_word_length": 4.88311688, "qsc_code_frac_words_unique": 0.2836637, "qsc_code_frac_chars_top_2grams": 0.02519597, "qsc_code_frac_chars_top_3grams": 0.00671892, "qsc_code_frac_chars_top_4grams": 0.0055991, "qsc_code_frac_chars_dupe_5grams": 0.22074468, "qsc_code_frac_chars_dupe_6grams": 0.18924972, "qsc_code_frac_chars_dupe_7grams": 0.17441209, "qsc_code_frac_chars_dupe_8grams": 0.15733483, "qsc_code_frac_chars_dupe_9grams": 0.15733483, "qsc_code_frac_chars_dupe_10grams": 0.14613662, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01130716, "qsc_code_frac_chars_whitespace": 0.25694765, "qsc_code_size_file_byte": 10831.0, "qsc_code_num_lines": 331.0, "qsc_code_num_chars_line_max": 82.0, "qsc_code_num_chars_line_mean": 32.72205438, "qsc_code_frac_chars_alphabet": 0.8763668, "qsc_code_frac_chars_comments": 0.20801403, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.1814301, "qsc_code_frac_chars_long_word_length": 0.01921025, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00426894, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codepython_cate_ast": 1.0, "qsc_codepython_frac_lines_func_ratio": 0.03703704, "qsc_codepython_cate_var_zero": false, "qsc_codepython_frac_lines_pass": 0.01234568, "qsc_codepython_frac_lines_import": 0.02469136, "qsc_codepython_frac_lines_simplefunc": 0.0, "qsc_codepython_score_lines_no_logic": 0.12345679, "qsc_codepython_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codepython_cate_ast": 0, "qsc_codepython_frac_lines_func_ratio": 0, "qsc_codepython_cate_var_zero": 0, "qsc_codepython_frac_lines_pass": 0, "qsc_codepython_frac_lines_import": 0, "qsc_codepython_frac_lines_simplefunc": 0, "qsc_codepython_score_lines_no_logic": 0, "qsc_codepython_frac_lines_print": 0} |
0-1-0/lightblue-0.4 | src/linux/obex.py | # Copyright (c) 2009 Bea Lam. All rights reserved.
#
# This file is part of LightBlue.
#
# LightBlue 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 3 of the License, or
# (at your option) any later version.
#
# LightBlue is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
"""
Provides an OBEX client class and convenience functions for sending and
receiving files over OBEX.
This module also defines constants for response code values (without the final
bit set). For example:
>>> import lightblue
>>> lightblue.obex.OK
32 # the OK/Success response 0x20 (i.e. 0xA0 without the final bit)
>>> lightblue.obex.FORBIDDEN
67 # the Forbidden response 0x43 (i.e. 0xC3 without the final bit)
"""
# Docstrings for attributes in this module.
_docstrings = {
"sendfile":
"""
Sends a file to a remote device.
Raises lightblue.obex.OBEXError if an error occurred during the request, or
if the request was refused by the remote device.
Arguments:
- address: the address of the remote device
- channel: the RFCOMM channel of the remote OBEX service
- source: a filename or file-like object, containing the data to be
sent. If a file object is given, it must be opened for reading.
Note you can achieve the same thing using OBEXClient with something like
this:
>>> import lightblue
>>> client = lightblue.obex.OBEXClient(address, channel)
>>> client.connect()
<OBEXResponse reason='OK' code=0x20 (0xa0) headers={}>
>>> putresponse = client.put({"name": "MyFile.txt"}, file("MyFile.txt", 'rb'))
>>> client.disconnect()
<OBEXResponse reason='OK' code=0x20 (0xa0) headers={}>
>>> if putresponse.code != lightblue.obex.OK:
... raise lightblue.obex.OBEXError("server denied the Put request")
>>>
""",
"recvfile":
"""
Receives a file through an OBEX service.
Arguments:
- sock: the server socket on which the file is to be received. Note
this socket must *not* be listening. Also, an OBEX service should
have been advertised on this socket.
- dest: a filename or file-like object, to which the received data will
be written. If a filename is given, any existing file will be
overwritten. If a file object is given, it must be opened for writing.
For example, to receive a file and save it as "MyFile.txt":
>>> from lightblue import *
>>> s = socket()
>>> s.bind(("", 0))
>>> advertise("My OBEX Service", s, OBEX)
>>> obex.recvfile(s, "MyFile.txt")
"""
}
# import implementation modules
from _obex import *
from _obexcommon import *
import _obex
import _obexcommon
__all__ = _obex.__all__ + _obexcommon.__all__
# set docstrings
localattrs = locals()
for attr in _obex.__all__:
try:
localattrs[attr].__doc__ = _docstrings[attr]
except KeyError:
pass
del attr, localattrs
| 3,421 | obex | py | en | python | code | {"qsc_code_num_words": 468, "qsc_code_num_chars": 3421.0, "qsc_code_mean_word_length": 4.86752137, "qsc_code_frac_words_unique": 0.41880342, "qsc_code_frac_chars_top_2grams": 0.03424056, "qsc_code_frac_chars_top_3grams": 0.01712028, "qsc_code_frac_chars_top_4grams": 0.02502195, "qsc_code_frac_chars_dupe_5grams": 0.12467076, "qsc_code_frac_chars_dupe_6grams": 0.11325724, "qsc_code_frac_chars_dupe_7grams": 0.0667252, "qsc_code_frac_chars_dupe_8grams": 0.03248464, "qsc_code_frac_chars_dupe_9grams": 0.03248464, "qsc_code_frac_chars_dupe_10grams": 0.03248464, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01152074, "qsc_code_frac_chars_whitespace": 0.23881906, "qsc_code_size_file_byte": 3421.0, "qsc_code_num_lines": 97.0, "qsc_code_num_chars_line_max": 87.0, "qsc_code_num_chars_line_mean": 35.26804124, "qsc_code_frac_chars_alphabet": 0.86328725, "qsc_code_frac_chars_comments": 0.35311312, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.04324324, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codepython_cate_ast": 1.0, "qsc_codepython_frac_lines_func_ratio": 0.0, "qsc_codepython_cate_var_zero": false, "qsc_codepython_frac_lines_pass": 0.05882353, "qsc_codepython_frac_lines_import": 0.23529412, "qsc_codepython_frac_lines_simplefunc": 0.0, "qsc_codepython_score_lines_no_logic": 0.23529412, "qsc_codepython_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codepython_cate_ast": 0, "qsc_codepython_frac_lines_func_ratio": 0, "qsc_codepython_cate_var_zero": 0, "qsc_codepython_frac_lines_pass": 1, "qsc_codepython_frac_lines_import": 0, "qsc_codepython_frac_lines_simplefunc": 0, "qsc_codepython_score_lines_no_logic": 0, "qsc_codepython_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blazing.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class Blazing extends Weapon.Enchantment {
private static ItemSprite.Glowing ORANGE = new ItemSprite.Glowing( 0xFF4400 );
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
// lvl 0 - 33%
// lvl 1 - 50%
// lvl 2 - 60%
int level = Math.max( 0, weapon.level() );
if (Random.Int( level + 3 ) >= 2) {
if (defender.buff(Burning.class) != null){
Buff.affect(defender, Burning.class).reignite(defender, 8f);
int burnDamage = Random.NormalIntRange( 1, 3 + Dungeon.depth/4 );
defender.damage( Math.round(burnDamage * 0.67f), this );
} else {
Buff.affect(defender, Burning.class).reignite(defender, 8f);
}
defender.sprite.emitter().burst( FlameParticle.FACTORY, level + 1 );
}
return damage;
}
@Override
public Glowing glowing() {
return ORANGE;
}
}
| 2,298 | Blazing | java | en | java | code | {"qsc_code_num_words": 290, "qsc_code_num_chars": 2298.0, "qsc_code_mean_word_length": 5.92413793, "qsc_code_frac_words_unique": 0.4862069, "qsc_code_frac_chars_top_2grams": 0.08905704, "qsc_code_frac_chars_top_3grams": 0.19906868, "qsc_code_frac_chars_top_4grams": 0.20488941, "qsc_code_frac_chars_dupe_5grams": 0.32479627, "qsc_code_frac_chars_dupe_6grams": 0.22351572, "qsc_code_frac_chars_dupe_7grams": 0.05587893, "qsc_code_frac_chars_dupe_8grams": 0.05587893, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02217638, "qsc_code_frac_chars_whitespace": 0.1562228, "qsc_code_size_file_byte": 2298.0, "qsc_code_num_lines": 66.0, "qsc_code_num_chars_line_max": 81.0, "qsc_code_num_chars_line_mean": 34.81818182, "qsc_code_frac_chars_alphabet": 0.86384734, "qsc_code_frac_chars_comments": 0.35813751, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.125, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00542373, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.0625, "qsc_codejava_score_lines_no_logic": 0.4375, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Chilling.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill;
import com.shatteredpixel.shatteredpixeldungeon.effects.Splash;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class Chilling extends Weapon.Enchantment {
private static ItemSprite.Glowing TEAL = new ItemSprite.Glowing( 0x00FFFF );
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
// lvl 0 - 33%
// lvl 1 - 50%
// lvl 2 - 60%
int level = Math.max( 0, weapon.level() );
if (Random.Int( level + 3 ) >= 2) {
//adds 3 turns of chill per proc, with a cap of 6 turns
float durationToAdd = 3f;
Chill existing = defender.buff(Chill.class);
if (existing != null){
durationToAdd = Math.min(durationToAdd, 6f-existing.cooldown());
}
Buff.affect( defender, Chill.class, durationToAdd );
Splash.at( defender.sprite.center(), 0xFFB2D6FF, 5);
}
return damage;
}
@Override
public Glowing glowing() {
return TEAL;
}
}
| 2,168 | Chilling | java | en | java | code | {"qsc_code_num_words": 281, "qsc_code_num_chars": 2168.0, "qsc_code_mean_word_length": 5.74733096, "qsc_code_frac_words_unique": 0.5088968, "qsc_code_frac_chars_top_2grams": 0.08421053, "qsc_code_frac_chars_top_3grams": 0.18823529, "qsc_code_frac_chars_top_4grams": 0.19071207, "qsc_code_frac_chars_dupe_5grams": 0.28606811, "qsc_code_frac_chars_dupe_6grams": 0.17832817, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02206288, "qsc_code_frac_chars_whitespace": 0.16374539, "qsc_code_size_file_byte": 2168.0, "qsc_code_num_lines": 65.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 33.35384615, "qsc_code_frac_chars_alphabet": 0.86872587, "qsc_code_frac_chars_comments": 0.40498155, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.06666667, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.01395349, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.43333333, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Kinetic.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2018 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
import com.watabou.utils.Bundle;
public class Kinetic extends Weapon.Enchantment {
private static ItemSprite.Glowing YELLOW = new ItemSprite.Glowing( 0xFFFF00 );
@Override
public int proc(Weapon weapon, Char attacker, Char defender, int damage) {
int conservedDamage = 0;
if (attacker.buff(ConservedDamage.class) != null) {
conservedDamage = attacker.buff(ConservedDamage.class).damageBonus();
attacker.buff(ConservedDamage.class).detach();
}
if (damage > defender.HP){
int extraDamage = damage - defender.HP;
Buff.affect(attacker, ConservedDamage.class).setBonus(extraDamage);
}
return damage + conservedDamage;
}
@Override
public ItemSprite.Glowing glowing() {
return YELLOW;
}
public static class ConservedDamage extends Buff {
@Override
public int icon() {
return BuffIndicator.WEAPON;
}
@Override
public void tintIcon(Image icon) {
if (preservedDamage >= 10){
icon.hardlight(1f, 0f, 0f);
} else if (preservedDamage >= 5) {
icon.hardlight(1f, 1f - (preservedDamage - 5f)*.2f, 0f);
} else {
icon.hardlight(1f, 1f, 1f - preservedDamage*.2f);
}
}
private float preservedDamage;
public void setBonus(int bonus){
preservedDamage = bonus;
}
public int damageBonus(){
return (int)Math.ceil(preservedDamage);
}
@Override
public boolean act() {
preservedDamage -= Math.max(preservedDamage*.025f, 0.1f);
if (preservedDamage <= 0) detach();
else if (preservedDamage <= 10) BuffIndicator.refreshHero();
spend(TICK);
return true;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", damageBonus());
}
private static final String PRESERVED_DAMAGE = "preserve_damage";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(PRESERVED_DAMAGE, preservedDamage);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
if (bundle.contains(PRESERVED_DAMAGE)){
preservedDamage = bundle.getFloat(PRESERVED_DAMAGE);
} else {
preservedDamage = cooldown()/10;
spend(cooldown());
}
}
}
}
| 3,552 | Kinetic | java | en | java | code | {"qsc_code_num_words": 405, "qsc_code_num_chars": 3552.0, "qsc_code_mean_word_length": 6.3382716, "qsc_code_frac_words_unique": 0.40740741, "qsc_code_frac_chars_top_2grams": 0.04908453, "qsc_code_frac_chars_top_3grams": 0.10362291, "qsc_code_frac_chars_top_4grams": 0.10284379, "qsc_code_frac_chars_dupe_5grams": 0.10907674, "qsc_code_frac_chars_dupe_6grams": 0.02181535, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01572112, "qsc_code_frac_chars_whitespace": 0.17623874, "qsc_code_size_file_byte": 3552.0, "qsc_code_num_lines": 126.0, "qsc_code_num_chars_line_max": 80.0, "qsc_code_num_chars_line_mean": 28.19047619, "qsc_code_frac_chars_alphabet": 0.86158578, "qsc_code_frac_chars_comments": 0.21987613, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13095238, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00830025, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00288704, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.11904762, "qsc_codejava_score_lines_no_logic": 0.26190476, "qsc_codejava_frac_words_no_modifier": 0.90909091, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Vampiric.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.watabou.utils.Random;
public class Vampiric extends Weapon.Enchantment {
private static ItemSprite.Glowing RED = new ItemSprite.Glowing( 0x660022 );
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
//chance to heal scales from 5%-30% based on missing HP
float missingPercent = (attacker.HT - attacker.HP) / (float)attacker.HT;
float healChance = 0.05f + .25f*missingPercent;
if (Random.Float() < healChance){
//heals for 50% of damage dealt
int healAmt = Math.round(damage * 0.5f);
healAmt = Math.min( healAmt, attacker.HT - attacker.HP );
if (healAmt > 0 && attacker.isAlive()) {
attacker.HP += healAmt;
attacker.sprite.emitter().start( Speck.factory( Speck.HEALING ), 0.4f, 1 );
attacker.sprite.showStatus( CharSprite.POSITIVE, Integer.toString( healAmt ) );
}
}
return damage;
}
@Override
public Glowing glowing() {
return RED;
}
}
| 2,227 | Vampiric | java | en | java | code | {"qsc_code_num_words": 284, "qsc_code_num_chars": 2227.0, "qsc_code_mean_word_length": 5.83450704, "qsc_code_frac_words_unique": 0.53169014, "qsc_code_frac_chars_top_2grams": 0.07181654, "qsc_code_frac_chars_top_3grams": 0.16053108, "qsc_code_frac_chars_top_4grams": 0.15932408, "qsc_code_frac_chars_dupe_5grams": 0.21303561, "qsc_code_frac_chars_dupe_6grams": 0.10742305, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02149382, "qsc_code_frac_chars_whitespace": 0.16434665, "qsc_code_size_file_byte": 2227.0, "qsc_code_num_lines": 64.0, "qsc_code_num_chars_line_max": 84.0, "qsc_code_num_chars_line_mean": 34.796875, "qsc_code_frac_chars_alphabet": 0.86888769, "qsc_code_frac_chars_comments": 0.38931298, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.06666667, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00588235, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.4, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Shocking.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.Lightning;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SparkParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
import java.util.ArrayList;
public class Shocking extends Weapon.Enchantment {
private static ItemSprite.Glowing WHITE = new ItemSprite.Glowing( 0xFFFFFF, 0.5f );
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
// lvl 0 - 33%
// lvl 1 - 50%
// lvl 2 - 60%
int level = Math.max( 0, weapon.level() );
if (Random.Int( level + 3 ) >= 2) {
affected.clear();
arcs.clear();
arc(attacker, defender, 2);
affected.remove(defender); //defender isn't hurt by lightning
for (Char ch : affected) {
ch.damage(Math.round(damage*0.4f), this);
}
attacker.sprite.parent.addToFront( new Lightning( arcs, null ) );
Sample.INSTANCE.play( Assets.SND_LIGHTNING );
}
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return WHITE;
}
private ArrayList<Char> affected = new ArrayList<>();
private ArrayList<Lightning.Arc> arcs = new ArrayList<>();
private void arc( Char attacker, Char defender, int dist ) {
affected.add(defender);
defender.sprite.centerEmitter().burst(SparkParticle.FACTORY, 3);
defender.sprite.flash();
PathFinder.buildDistanceMap( defender.pos, BArray.not( Dungeon.level.solid, null ), dist );
for (int i = 0; i < PathFinder.distance.length; i++) {
if (PathFinder.distance[i] < Integer.MAX_VALUE) {
Char n = Actor.findChar(i);
if (n != null && n != attacker && !affected.contains(n)) {
arcs.add(new Lightning.Arc(defender.sprite.center(), n.sprite.center()));
arc(attacker, n, (Dungeon.level.water[n.pos] && !n.flying) ? 2 : 1);
}
}
}
}
}
| 3,098 | Shocking | java | en | java | code | {"qsc_code_num_words": 394, "qsc_code_num_chars": 3098.0, "qsc_code_mean_word_length": 5.73350254, "qsc_code_frac_words_unique": 0.42893401, "qsc_code_frac_chars_top_2grams": 0.04780876, "qsc_code_frac_chars_top_3grams": 0.16821602, "qsc_code_frac_chars_top_4grams": 0.1752988, "qsc_code_frac_chars_dupe_5grams": 0.19300575, "qsc_code_frac_chars_dupe_6grams": 0.02478973, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01187285, "qsc_code_frac_chars_whitespace": 0.15719819, "qsc_code_size_file_byte": 3098.0, "qsc_code_num_lines": 94.0, "qsc_code_num_chars_line_max": 94.0, "qsc_code_num_chars_line_mean": 32.95744681, "qsc_code_frac_chars_alphabet": 0.85331291, "qsc_code_frac_chars_comments": 0.25338928, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.03703704, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00345871, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.03703704, "qsc_codejava_score_lines_no_logic": 0.33333333, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Corrupting.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Corruption;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.PinCushion;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.SoulMark;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Corrupting extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x440066 );
@Override
public int proc(Weapon weapon, Char attacker, Char defender, int damage) {
if (defender.buff(Corruption.class) != null || !(defender instanceof Mob)) return damage;
int level = Math.max( 0, weapon.level() );
// lvl 0 - 20%
// lvl 1 ~ 22.5%
// lvl 2 ~ 25%
if (damage >= defender.HP
&& !defender.isImmune(Corruption.class)
&& Random.Int( level + 30 ) >= 24){
Mob enemy = (Mob) defender;
Hero hero = (attacker instanceof Hero) ? (Hero) attacker : Dungeon.hero;
enemy.HP = enemy.HT;
for (Buff buff : enemy.buffs()) {
if (buff.type == Buff.buffType.NEGATIVE
&& !(buff instanceof SoulMark)) {
buff.detach();
} else if (buff instanceof PinCushion){
buff.detach();
}
}
if (enemy.alignment == Char.Alignment.ENEMY){
enemy.rollToDropLoot();
}
Buff.affect(enemy, Corruption.class);
Statistics.enemiesSlain++;
Badges.validateMonstersSlain();
Statistics.qualifiedForNoKilling = false;
if (enemy.EXP > 0 && hero.lvl <= enemy.maxLvl) {
hero.sprite.showStatus(CharSprite.POSITIVE, Messages.get(enemy, "exp", enemy.EXP));
hero.earnExp(enemy.EXP, enemy.getClass());
} else {
hero.earnExp(0, enemy.getClass());
}
return 0;
}
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
}
| 3,301 | Corrupting | java | en | java | code | {"qsc_code_num_words": 391, "qsc_code_num_chars": 3301.0, "qsc_code_mean_word_length": 6.24808184, "qsc_code_frac_words_unique": 0.41176471, "qsc_code_frac_chars_top_2grams": 0.10437986, "qsc_code_frac_chars_top_3grams": 0.23331969, "qsc_code_frac_chars_top_4grams": 0.252149, "qsc_code_frac_chars_dupe_5grams": 0.26688498, "qsc_code_frac_chars_dupe_6grams": 0.11297585, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01506456, "qsc_code_frac_chars_whitespace": 0.15540745, "qsc_code_size_file_byte": 3301.0, "qsc_code_num_lines": 95.0, "qsc_code_num_chars_line_max": 92.0, "qsc_code_num_chars_line_mean": 34.74736842, "qsc_code_frac_chars_alphabet": 0.86119082, "qsc_code_frac_chars_comments": 0.24962133, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.06896552, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00121114, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00322971, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.01724138, "qsc_codejava_score_lines_no_logic": 0.34482759, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/enchantments/Blooming.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2018 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.LeafParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
import java.util.ArrayList;
public class Blooming extends Weapon.Enchantment {
private static ItemSprite.Glowing DARK_GREEN = new ItemSprite.Glowing( 0x008800 );
@Override
public int proc(Weapon weapon, Char attacker, Char defender, int damage) {
// lvl 0 - 33%
// lvl 1 - 50%
// lvl 2 - 60%
int level = Math.max( 0, weapon.level() );
if (Random.Int( level + 3 ) >= 2) {
boolean secondPlant = level > Random.Int(10);
if (plantGrass(defender.pos)){
if (secondPlant) secondPlant = false;
else return damage;
}
ArrayList<Integer> positions = new ArrayList<>();
for (int i : PathFinder.NEIGHBOURS8){
positions.add(i);
}
Random.shuffle( positions );
for (int i : positions){
if (plantGrass(defender.pos + i)){
if (secondPlant) secondPlant = false;
else return damage;
}
}
}
return damage;
}
private boolean plantGrass(int cell){
int c = Dungeon.level.map[cell];
if ( c == Terrain.EMPTY || c == Terrain.EMPTY_DECO
|| c == Terrain.EMBERS || c == Terrain.GRASS){
Level.set(cell, Terrain.HIGH_GRASS);
GameScene.updateMap(cell);
CellEmitter.get( cell ).burst( LeafParticle.LEVEL_SPECIFIC, 4 );
return true;
}
return false;
}
@Override
public ItemSprite.Glowing glowing() {
return DARK_GREEN;
}
}
| 2,848 | Blooming | java | en | java | code | {"qsc_code_num_words": 352, "qsc_code_num_chars": 2848.0, "qsc_code_mean_word_length": 5.91193182, "qsc_code_frac_words_unique": 0.45454545, "qsc_code_frac_chars_top_2grams": 0.04757328, "qsc_code_frac_chars_top_3grams": 0.18260452, "qsc_code_frac_chars_top_4grams": 0.19029313, "qsc_code_frac_chars_dupe_5grams": 0.22681403, "qsc_code_frac_chars_dupe_6grams": 0.07015858, "qsc_code_frac_chars_dupe_7grams": 0.04324844, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01690617, "qsc_code_frac_chars_whitespace": 0.16924157, "qsc_code_size_file_byte": 2848.0, "qsc_code_num_lines": 90.0, "qsc_code_num_chars_line_max": 84.0, "qsc_code_num_chars_line_mean": 31.64444444, "qsc_code_frac_chars_alphabet": 0.86263736, "qsc_code_frac_chars_comments": 0.28897472, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.11111111, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00395062, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.03703704, "qsc_codejava_score_lines_no_logic": 0.35185185, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/ForceCube.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.PathFinder;
import java.util.ArrayList;
public class ForceCube extends MissileWeapon {
{
image = ItemSpriteSheet.FORCE_CUBE;
tier = 5;
baseUses = 5;
sticky = false;
}
@Override
protected void onThrow(int cell) {
Dungeon.level.pressCell(cell);
ArrayList<Char> targets = new ArrayList<>();
if (Actor.findChar(cell) != null) targets.add(Actor.findChar(cell));
for (int i : PathFinder.NEIGHBOURS8){
Dungeon.level.pressCell(cell);
if (Actor.findChar(cell + i) != null) targets.add(Actor.findChar(cell + i));
}
for (Char target : targets){
curUser.shoot(target, this);
if (target == Dungeon.hero && !target.isAlive()){
Dungeon.fail(getClass());
GLog.n(Messages.get(this, "ondeath"));
}
}
rangedHit( null, cell );
WandOfBlastWave.BlastWave.blast(cell);
Sample.INSTANCE.play( Assets.SND_BLAST );
}
}
| 2,307 | ForceCube | java | en | java | code | {"qsc_code_num_words": 287, "qsc_code_num_chars": 2307.0, "qsc_code_mean_word_length": 6.0174216, "qsc_code_frac_words_unique": 0.51567944, "qsc_code_frac_chars_top_2grams": 0.05211349, "qsc_code_frac_chars_top_3grams": 0.19803127, "qsc_code_frac_chars_top_4grams": 0.20382166, "qsc_code_frac_chars_dupe_5grams": 0.14128547, "qsc_code_frac_chars_dupe_6grams": 0.06832658, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01019368, "qsc_code_frac_chars_whitespace": 0.14954486, "qsc_code_size_file_byte": 2307.0, "qsc_code_num_lines": 73.0, "qsc_code_num_chars_line_max": 80.0, "qsc_code_num_chars_line_mean": 31.60273973, "qsc_code_frac_chars_alphabet": 0.87003058, "qsc_code_frac_chars_comments": 0.33810143, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.05, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00458415, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.025, "qsc_codejava_score_lines_no_logic": 0.325, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/Dart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicImmune;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Crossbow;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import java.util.ArrayList;
public class Dart extends MissileWeapon {
{
image = ItemSpriteSheet.DART;
tier = 1;
//infinite, even with penalties
baseUses = 1000;
}
protected static final String AC_TIP = "TIP";
@Override
public ArrayList<String> actions(Hero hero) {
ArrayList<String> actions = super.actions( hero );
actions.add( AC_TIP );
return actions;
}
@Override
public void execute(Hero hero, String action) {
if (action.equals(AC_TIP)){
GameScene.selectItem(itemSelector, WndBag.Mode.SEED, "select a seed");
}
super.execute(hero, action);
}
@Override
public int min(int lvl) {
if (bow != null){
return 4 + //4 base
bow.level() + lvl; //+1 per level or bow level
} else {
return 1 + //1 base, down from 2
lvl; //scaling unchanged
}
}
@Override
public int max(int lvl) {
if (bow != null){
return 12 + //12 base
3*bow.level() + 2*lvl; //+3 per bow level, +2 per level (default scaling +2)
} else {
return 2 + //2 base, down from 5
2*lvl; //scaling unchanged
}
}
private static Crossbow bow;
private void updateCrossbow(){
if (Dungeon.hero.belongings.weapon instanceof Crossbow){
bow = (Crossbow) Dungeon.hero.belongings.weapon;
} else {
bow = null;
}
}
@Override
public boolean hasEnchant(Class<? extends Enchantment> type, Char owner) {
if (bow != null && bow.hasEnchant(type, owner)){
return true;
} else {
return super.hasEnchant(type, owner);
}
}
@Override
public int proc(Char attacker, Char defender, int damage) {
if (bow != null && bow.enchantment != null && attacker.buff(MagicImmune.class) == null){
level(bow.level());
damage = bow.enchantment.proc(this, attacker, defender, damage);
level(0);
}
return super.proc(attacker, defender, damage);
}
@Override
protected void onThrow(int cell) {
updateCrossbow();
super.onThrow(cell);
}
@Override
public String info() {
updateCrossbow();
return super.info();
}
@Override
public boolean isUpgradable() {
return false;
}
@Override
public int price() {
return super.price()/2; //half normal value
}
private final WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect(final Item item) {
if (item == null) return;
final int maxToTip = Math.min(curItem.quantity(), item.quantity()*2);
final int maxSeedsToUse = (maxToTip+1)/2;
final int singleSeedDarts;
final String[] options;
if (curItem.quantity() == 1){
singleSeedDarts = 1;
options = new String[]{
Messages.get(Dart.class, "tip_one"),
Messages.get(Dart.class, "tip_cancel")};
} else {
singleSeedDarts = 2;
if (maxToTip <= 2){
options = new String[]{
Messages.get(Dart.class, "tip_two"),
Messages.get(Dart.class, "tip_cancel")};
} else {
options = new String[]{
Messages.get(Dart.class, "tip_all", maxToTip, maxSeedsToUse),
Messages.get(Dart.class, "tip_two"),
Messages.get(Dart.class, "tip_cancel")};
}
}
TippedDart tipResult = TippedDart.getTipped((Plant.Seed) item, 1);
GameScene.show(new WndOptions(Messages.get(Dart.class, "tip_title"),
Messages.get(Dart.class, "tip_desc", tipResult.name()) + "\n\n" + tipResult.desc(),
options){
@Override
protected void onSelect(int index) {
super.onSelect(index);
if (index == 0 && options.length == 3){
if (item.quantity() <= maxSeedsToUse){
item.detachAll( curUser.belongings.backpack );
} else {
item.quantity(item.quantity() - maxSeedsToUse);
}
if (maxToTip < curItem.quantity()){
curItem.quantity(curItem.quantity() - maxToTip);
} else {
curItem.detachAll(curUser.belongings.backpack);
}
TippedDart newDart = TippedDart.getTipped((Plant.Seed) item, maxToTip);
if (!newDart.collect()) Dungeon.level.drop(newDart, curUser.pos).sprite.drop();
curUser.spend( 1f );
curUser.busy();
curUser.sprite.operate(curUser.pos);
} else if ((index == 1 && options.length == 3) || (index == 0 && options.length == 2)){
item.detach( curUser.belongings.backpack );
if (curItem.quantity() <= singleSeedDarts){
curItem.detachAll( curUser.belongings.backpack );
} else {
curItem.quantity(curItem.quantity() - singleSeedDarts);
}
TippedDart newDart = TippedDart.getTipped((Plant.Seed) item, singleSeedDarts);
if (!newDart.collect()) Dungeon.level.drop(newDart, curUser.pos).sprite.drop();
curUser.spend( 1f );
curUser.busy();
curUser.sprite.operate(curUser.pos);
}
}
});
}
};
}
| 6,551 | Dart | java | en | java | code | {"qsc_code_num_words": 753, "qsc_code_num_chars": 6551.0, "qsc_code_mean_word_length": 5.84063745, "qsc_code_frac_words_unique": 0.2934927, "qsc_code_frac_chars_top_2grams": 0.05411551, "qsc_code_frac_chars_top_3grams": 0.12096407, "qsc_code_frac_chars_top_4grams": 0.13005912, "qsc_code_frac_chars_dupe_5grams": 0.31127785, "qsc_code_frac_chars_dupe_6grams": 0.19099591, "qsc_code_frac_chars_dupe_7grams": 0.12892224, "qsc_code_frac_chars_dupe_8grams": 0.09822647, "qsc_code_frac_chars_dupe_9grams": 0.07685312, "qsc_code_frac_chars_dupe_10grams": 0.07685312, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01133308, "qsc_code_frac_chars_whitespace": 0.20531217, "qsc_code_size_file_byte": 6551.0, "qsc_code_num_lines": 226.0, "qsc_code_num_chars_line_max": 93.0, "qsc_code_num_chars_line_mean": 28.98672566, "qsc_code_frac_chars_alphabet": 0.83346139, "qsc_code_frac_chars_comments": 0.15386964, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.26060606, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01713873, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.07272727, "qsc_codejava_score_lines_no_logic": 0.19393939, "qsc_codejava_frac_words_no_modifier": 0.92307692, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/HealingDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Healing;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class HealingDart extends TippedDart {
{
image = ItemSpriteSheet.HEALING_DART;
}
@Override
public int proc(Char attacker, Char defender, int damage) {
//heals 30 hp at base, scaling with enemy HT
Buff.affect( defender, Healing.class ).setHeal((int)(0.5f*defender.HT + 30), 0.25f, 0);
PotionOfHealing.cure( defender );
if (attacker.alignment == defender.alignment){
return 0;
}
return super.proc(attacker, defender, damage);
}
}
| 1,685 | HealingDart | java | en | java | code | {"qsc_code_num_words": 221, "qsc_code_num_chars": 1685.0, "qsc_code_mean_word_length": 5.79638009, "qsc_code_frac_words_unique": 0.56108597, "qsc_code_frac_chars_top_2grams": 0.07962529, "qsc_code_frac_chars_top_3grams": 0.17798595, "qsc_code_frac_chars_top_4grams": 0.17174083, "qsc_code_frac_chars_dupe_5grams": 0.18891491, "qsc_code_frac_chars_dupe_6grams": 0.12958626, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01967674, "qsc_code_frac_chars_whitespace": 0.15548961, "qsc_code_size_file_byte": 1685.0, "qsc_code_num_lines": 50.0, "qsc_code_num_chars_line_max": 90.0, "qsc_code_num_chars_line_mean": 33.7, "qsc_code_frac_chars_alphabet": 0.88053408, "qsc_code_frac_chars_comments": 0.48961424, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.05, "qsc_codejava_score_lines_no_logic": 0.4, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/RotDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Corrosion;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class RotDart extends TippedDart {
{
image = ItemSpriteSheet.ROT_DART;
}
@Override
public int proc(Char attacker, Char defender, int damage) {
if (defender.properties().contains(Char.Property.BOSS)
|| defender.properties().contains(Char.Property.MINIBOSS)){
Buff.affect(defender, Corrosion.class).set(5f, Dungeon.depth/3);
} else{
Buff.affect(defender, Corrosion.class).set(10f, Dungeon.depth);
}
return super.proc(attacker, defender, damage);
}
@Override
protected float durabilityPerUse() {
return 100f;
}
}
| 1,753 | RotDart | java | en | java | code | {"qsc_code_num_words": 224, "qsc_code_num_chars": 1753.0, "qsc_code_mean_word_length": 5.95535714, "qsc_code_frac_words_unique": 0.55357143, "qsc_code_frac_chars_top_2grams": 0.07646177, "qsc_code_frac_chars_top_3grams": 0.17091454, "qsc_code_frac_chars_top_4grams": 0.16491754, "qsc_code_frac_chars_dupe_5grams": 0.29085457, "qsc_code_frac_chars_dupe_6grams": 0.17691154, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01609658, "qsc_code_frac_chars_whitespace": 0.14945807, "qsc_code_size_file_byte": 1753.0, "qsc_code_num_lines": 54.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 32.46296296, "qsc_code_frac_chars_alphabet": 0.87860496, "qsc_code_frac_chars_comments": 0.44552196, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.08, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.08, "qsc_codejava_score_lines_no_logic": 0.36, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/DisplacingDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.utils.Random;
import java.util.ArrayList;
import java.util.HashMap;
public class DisplacingDart extends TippedDart {
{
image = ItemSpriteSheet.DISPLACING_DART;
}
int distance = 8;
@Override
public int proc(Char attacker, Char defender, int damage) {
if (!defender.properties().contains(Char.Property.IMMOVABLE)){
int startDist = Dungeon.level.distance(attacker.pos, defender.pos);
HashMap<Integer, ArrayList<Integer>> positions = new HashMap<>();
for (int pos = 0; pos < Dungeon.level.length(); pos++){
if (Dungeon.level.heroFOV[pos]
&& Dungeon.level.passable[pos]
&& Actor.findChar(pos) == null){
int dist = Dungeon.level.distance(attacker.pos, pos);
if (dist > startDist){
if (positions.get(dist) == null){
positions.put(dist, new ArrayList<Integer>());
}
positions.get(dist).add(pos);
}
}
}
float[] probs = new float[distance+1];
for (int i = 0; i <= distance; i++){
if (positions.get(i) != null){
probs[i] = i - startDist;
}
}
int chosenDist = Random.chances(probs);
if (chosenDist != -1){
int pos = positions.get(chosenDist).get(Random.index(positions.get(chosenDist)));
ScrollOfTeleportation.appear( defender, pos );
Dungeon.level.occupyCell(defender );
}
}
return super.proc(attacker, defender, damage);
}
}
| 2,620 | DisplacingDart | java | en | java | code | {"qsc_code_num_words": 321, "qsc_code_num_chars": 2620.0, "qsc_code_mean_word_length": 5.73831776, "qsc_code_frac_words_unique": 0.45794393, "qsc_code_frac_chars_top_2grams": 0.05537459, "qsc_code_frac_chars_top_3grams": 0.1237785, "qsc_code_frac_chars_top_4grams": 0.1194354, "qsc_code_frac_chars_dupe_5grams": 0.13246471, "qsc_code_frac_chars_dupe_6grams": 0.03040174, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01032379, "qsc_code_frac_chars_whitespace": 0.18664122, "qsc_code_size_file_byte": 2620.0, "qsc_code_num_lines": 87.0, "qsc_code_num_chars_line_max": 86.0, "qsc_code_num_chars_line_mean": 30.11494253, "qsc_code_frac_chars_alphabet": 0.85405913, "qsc_code_frac_chars_comments": 0.2980916, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.02083333, "qsc_codejava_score_lines_no_logic": 0.20833333, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/PoisonDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class PoisonDart extends TippedDart {
{
image = ItemSpriteSheet.POISON_DART;
}
@Override
public int proc(Char attacker, Char defender, int damage) {
Buff.affect( defender, Poison.class ).set( 3 + Dungeon.depth / 3 );
return super.proc(attacker, defender, damage);
}
}
| 1,486 | PoisonDart | java | en | java | code | {"qsc_code_num_words": 195, "qsc_code_num_chars": 1486.0, "qsc_code_mean_word_length": 5.85128205, "qsc_code_frac_words_unique": 0.56923077, "qsc_code_frac_chars_top_2grams": 0.08939527, "qsc_code_frac_chars_top_3grams": 0.19982472, "qsc_code_frac_chars_top_4grams": 0.19281332, "qsc_code_frac_chars_dupe_5grams": 0.21209465, "qsc_code_frac_chars_dupe_6grams": 0.14548642, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01511535, "qsc_code_frac_chars_whitespace": 0.15410498, "qsc_code_size_file_byte": 1486.0, "qsc_code_num_lines": 43.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 34.55813953, "qsc_code_frac_chars_alphabet": 0.89260143, "qsc_code_frac_chars_comments": 0.52557201, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.0625, "qsc_codejava_score_lines_no_logic": 0.4375, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/SleepDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Sleep;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class SleepDart extends TippedDart {
{
image = ItemSpriteSheet.SLEEP_DART;
}
@Override
public int proc(Char attacker, final Char defender, int damage) {
//need to delay this so damage from the dart doesn't break the sleep
new FlavourBuff(){
{actPriority = VFX_PRIO;}
public boolean act() {
Buff.affect( defender, Sleep.class );
return super.act();
}
}.attachTo(defender);
return super.proc(attacker, defender, damage);
}
}
| 1,678 | SleepDart | java | en | java | code | {"qsc_code_num_words": 220, "qsc_code_num_chars": 1678.0, "qsc_code_mean_word_length": 5.77727273, "qsc_code_frac_words_unique": 0.57272727, "qsc_code_frac_chars_top_2grams": 0.08025177, "qsc_code_frac_chars_top_3grams": 0.17938631, "qsc_code_frac_chars_top_4grams": 0.17309205, "qsc_code_frac_chars_dupe_5grams": 0.23367427, "qsc_code_frac_chars_dupe_6grams": 0.17387884, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01208244, "qsc_code_frac_chars_whitespace": 0.16150179, "qsc_code_size_file_byte": 1678.0, "qsc_code_num_lines": 50.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 33.56, "qsc_code_frac_chars_alphabet": 0.891258, "qsc_code_frac_chars_comments": 0.50595948, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.13636364, "qsc_codejava_score_lines_no_logic": 0.40909091, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/BlindingDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class BlindingDart extends TippedDart {
{
image = ItemSpriteSheet.BLINDING_DART;
}
@Override
public int proc(Char attacker, Char defender, int damage) {
Buff.affect(defender, Blindness.class, 10f);
return super.proc(attacker, defender, damage);
}
}
| 1,414 | BlindingDart | java | en | java | code | {"qsc_code_num_words": 186, "qsc_code_num_chars": 1414.0, "qsc_code_mean_word_length": 5.83870968, "qsc_code_frac_words_unique": 0.59677419, "qsc_code_frac_chars_top_2grams": 0.07826888, "qsc_code_frac_chars_top_3grams": 0.17495396, "qsc_code_frac_chars_top_4grams": 0.16206262, "qsc_code_frac_chars_dupe_5grams": 0.2228361, "qsc_code_frac_chars_dupe_6grams": 0.15285451, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01592624, "qsc_code_frac_chars_whitespace": 0.1562942, "qsc_code_size_file_byte": 1414.0, "qsc_code_num_lines": 43.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 32.88372093, "qsc_code_frac_chars_alphabet": 0.89438391, "qsc_code_frac_chars_comments": 0.5523338, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.4, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/IncendiaryDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class IncendiaryDart extends TippedDart {
{
image = ItemSpriteSheet.INCENDIARY_DART;
}
@Override
protected void onThrow( int cell ) {
Char enemy = Actor.findChar( cell );
if ((enemy == null || enemy == curUser) && Dungeon.level.flamable[cell]) {
GameScene.add(Blob.seed(cell, 4, Fire.class));
Dungeon.level.drop(new Dart(), cell).sprite.drop();
} else{
super.onThrow(cell);
}
}
@Override
public int proc( Char attacker, Char defender, int damage ) {
Buff.affect( defender, Burning.class ).reignite( defender );
return super.proc( attacker, defender, damage );
}
}
| 2,061 | IncendiaryDart | java | en | java | code | {"qsc_code_num_words": 258, "qsc_code_num_chars": 2061.0, "qsc_code_mean_word_length": 6.12790698, "qsc_code_frac_words_unique": 0.51937984, "qsc_code_frac_chars_top_2grams": 0.10752688, "qsc_code_frac_chars_top_3grams": 0.24035421, "qsc_code_frac_chars_top_4grams": 0.25047438, "qsc_code_frac_chars_dupe_5grams": 0.25426945, "qsc_code_frac_chars_dupe_6grams": 0.17457306, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01015801, "qsc_code_frac_chars_whitespace": 0.14022319, "qsc_code_size_file_byte": 2061.0, "qsc_code_num_lines": 56.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 36.80357143, "qsc_code_frac_chars_alphabet": 0.88205418, "qsc_code_frac_chars_comments": 0.37894226, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.06666667, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.4, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/ThrowingHammer.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class ThrowingHammer extends MissileWeapon {
{
image = ItemSpriteSheet.THROWING_HAMMER;
tier = 5;
baseUses = 15;
sticky = false;
}
@Override
public int max(int lvl) {
return 4 * tier + //20 base, down from 25
(tier) * lvl; //scaling unchanged
}
}
| 1,242 | ThrowingHammer | java | en | java | code | {"qsc_code_num_words": 167, "qsc_code_num_chars": 1242.0, "qsc_code_mean_word_length": 5.31137725, "qsc_code_frac_words_unique": 0.68263473, "qsc_code_frac_chars_top_2grams": 0.03720406, "qsc_code_frac_chars_top_3grams": 0.04396843, "qsc_code_frac_chars_top_4grams": 0.06426156, "qsc_code_frac_chars_dupe_5grams": 0.09244645, "qsc_code_frac_chars_dupe_6grams": 0.06313416, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02556237, "qsc_code_frac_chars_whitespace": 0.21256039, "qsc_code_size_file_byte": 1242.0, "qsc_code_num_lines": 41.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 30.29268293, "qsc_code_frac_chars_alphabet": 0.88139059, "qsc_code_frac_chars_comments": 0.6626409, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.2, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Shuriken.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class Shuriken extends MissileWeapon {
{
image = ItemSpriteSheet.SHURIKEN;
tier = 2;
baseUses = 5;
}
@Override
public int max(int lvl) {
return 4 * tier + //8 base, down from 10
(tier == 1 ? 2*lvl : tier*lvl); //scaling unchanged
}
@Override
public float speedFactor(Char owner) {
if (owner instanceof Hero && ((Hero) owner).justMoved) return 0;
else return super.speedFactor(owner);
}
}
| 1,557 | Shuriken | java | en | java | code | {"qsc_code_num_words": 201, "qsc_code_num_chars": 1557.0, "qsc_code_mean_word_length": 5.46766169, "qsc_code_frac_words_unique": 0.60696517, "qsc_code_frac_chars_top_2grams": 0.06187443, "qsc_code_frac_chars_top_3grams": 0.13830755, "qsc_code_frac_chars_top_4grams": 0.05186533, "qsc_code_frac_chars_dupe_5grams": 0.1656051, "qsc_code_frac_chars_dupe_6grams": 0.05095541, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0212766, "qsc_code_frac_chars_whitespace": 0.21515735, "qsc_code_size_file_byte": 1557.0, "qsc_code_num_lines": 47.0, "qsc_code_num_chars_line_max": 91.0, "qsc_code_num_chars_line_mean": 33.12765957, "qsc_code_frac_chars_alphabet": 0.87806874, "qsc_code_frac_chars_comments": 0.52793834, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0952381, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.0952381, "qsc_codejava_score_lines_no_logic": 0.28571429, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Kunai.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.utils.Random;
public class Kunai extends MissileWeapon {
{
image = ItemSpriteSheet.KUNAI;
tier = 3;
baseUses = 5;
}
private Char enemy;
@Override
protected void onThrow(int cell) {
enemy = Actor.findChar(cell);
super.onThrow(cell);
}
@Override
public int damageRoll(Char owner) {
if (owner instanceof Hero) {
Hero hero = (Hero)owner;
if (enemy instanceof Mob && ((Mob) enemy).surprisedBy(hero)) {
//deals 60% toward max to max on surprise, instead of min to max.
int diff = max() - min();
int damage = augment.damageFactor(Random.NormalIntRange(
min() + Math.round(diff*0.6f),
max()));
int exStr = hero.STR() - STRReq();
if (exStr > 0) {
damage += Random.IntRange(0, exStr);
}
return damage;
}
}
return super.damageRoll(owner);
}
}
| 2,026 | Kunai | java | en | java | code | {"qsc_code_num_words": 264, "qsc_code_num_chars": 2026.0, "qsc_code_mean_word_length": 5.53787879, "qsc_code_frac_words_unique": 0.53787879, "qsc_code_frac_chars_top_2grams": 0.06976744, "qsc_code_frac_chars_top_3grams": 0.15595075, "qsc_code_frac_chars_top_4grams": 0.1504788, "qsc_code_frac_chars_dupe_5grams": 0.19288646, "qsc_code_frac_chars_dupe_6grams": 0.03830369, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01508751, "qsc_code_frac_chars_whitespace": 0.18213228, "qsc_code_size_file_byte": 2026.0, "qsc_code_num_lines": 68.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 29.79411765, "qsc_code_frac_chars_alphabet": 0.86722993, "qsc_code_frac_chars_comments": 0.41707799, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.05263158, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.05263158, "qsc_codejava_score_lines_no_logic": 0.28947368, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/ThrowingKnife.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.utils.Random;
public class ThrowingKnife extends MissileWeapon {
{
image = ItemSpriteSheet.THROWING_KNIFE;
bones = false;
tier = 1;
baseUses = 5;
}
@Override
public int max(int lvl) {
return 6 * tier + //6 base, up from 5
(tier == 1 ? 2*lvl : tier*lvl); //scaling unchanged
}
private Char enemy;
@Override
protected void onThrow(int cell) {
enemy = Actor.findChar(cell);
super.onThrow(cell);
}
@Override
public int damageRoll(Char owner) {
if (owner instanceof Hero) {
Hero hero = (Hero)owner;
if (enemy instanceof Mob && ((Mob) enemy).surprisedBy(hero)) {
//deals 75% toward max to max on surprise, instead of min to max.
int diff = max() - min();
int damage = augment.damageFactor(Random.NormalIntRange(
min() + Math.round(diff*0.75f),
max()));
int exStr = hero.STR() - STRReq();
if (exStr > 0) {
damage += Random.IntRange(0, exStr);
}
return damage;
}
}
return super.damageRoll(owner);
}
}
| 2,224 | ThrowingKnife | java | en | java | code | {"qsc_code_num_words": 289, "qsc_code_num_chars": 2224.0, "qsc_code_mean_word_length": 5.43252595, "qsc_code_frac_words_unique": 0.53633218, "qsc_code_frac_chars_top_2grams": 0.06496815, "qsc_code_frac_chars_top_3grams": 0.14522293, "qsc_code_frac_chars_top_4grams": 0.14012739, "qsc_code_frac_chars_dupe_5grams": 0.17961783, "qsc_code_frac_chars_dupe_6grams": 0.03566879, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01732812, "qsc_code_frac_chars_whitespace": 0.19559353, "qsc_code_size_file_byte": 2224.0, "qsc_code_num_lines": 75.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 29.65333333, "qsc_code_frac_chars_alphabet": 0.86025713, "qsc_code_frac_chars_comments": 0.39748201, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.06818182, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.06818182, "qsc_codejava_score_lines_no_logic": 0.27272727, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/ThrowingStone.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class ThrowingStone extends MissileWeapon {
{
image = ItemSpriteSheet.THROWING_STONE;
bones = false;
tier = 1;
baseUses = 5;
sticky = false;
}
@Override
public int price() {
return super.price()/2; //half normal value
}
}
| 1,186 | ThrowingStone | java | en | java | code | {"qsc_code_num_words": 162, "qsc_code_num_chars": 1186.0, "qsc_code_mean_word_length": 5.38271605, "qsc_code_frac_words_unique": 0.68518519, "qsc_code_frac_chars_top_2grams": 0.03784404, "qsc_code_frac_chars_top_3grams": 0.04472477, "qsc_code_frac_chars_top_4grams": 0.06536697, "qsc_code_frac_chars_dupe_5grams": 0.0940367, "qsc_code_frac_chars_dupe_6grams": 0.06422018, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02081165, "qsc_code_frac_chars_whitespace": 0.18971332, "qsc_code_size_file_byte": 1186.0, "qsc_code_num_lines": 42.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 28.23809524, "qsc_code_frac_chars_alphabet": 0.88657648, "qsc_code_frac_chars_comments": 0.67453626, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.2, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Corruption;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.PinCushion;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.MagicalHolster;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Projecting;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
import java.util.ArrayList;
abstract public class MissileWeapon extends Weapon {
{
stackable = true;
levelKnown = true;
bones = true;
defaultAction = AC_THROW;
usesTargeting = true;
}
protected boolean sticky = true;
protected static final float MAX_DURABILITY = 100;
protected float durability = MAX_DURABILITY;
protected float baseUses = 10;
public boolean holster;
//used to reduce durability from the source weapon stack, rather than the one being thrown.
protected MissileWeapon parent;
public int tier;
@Override
public int min() {
return Math.max(0, min( level() + RingOfSharpshooting.levelDamageBonus(Dungeon.hero) ));
}
@Override
public int min(int lvl) {
return 2 * tier + //base
(tier == 1 ? lvl : 2*lvl); //level scaling
}
@Override
public int max() {
return Math.max(0, max( level() + RingOfSharpshooting.levelDamageBonus(Dungeon.hero) ));
}
@Override
public int max(int lvl) {
return 5 * tier + //base
(tier == 1 ? 2*lvl : tier*lvl); //level scaling
}
public int STRReq(int lvl){
lvl = Math.max(0, lvl);
//strength req decreases at +1,+3,+6,+10,etc.
return (7 + tier * 2) - (int)(Math.sqrt(8 * lvl + 1) - 1)/2;
}
@Override
//FIXME some logic here assumes the items are in the player's inventory. Might need to adjust
public Item upgrade() {
if (!bundleRestoring) {
if (quantity > 1) {
MissileWeapon upgraded = (MissileWeapon) split(1);
upgraded.parent = null;
upgraded = (MissileWeapon) upgraded.upgrade();
//try to put the upgraded into inventory, if it didn't already merge
if (upgraded.quantity() == 1 && !upgraded.collect()) {
Dungeon.level.drop(upgraded, Dungeon.hero.pos);
}
updateQuickslot();
return upgraded;
} else {
durability = MAX_DURABILITY;
super.upgrade();
Item similar = Dungeon.hero.belongings.getSimilar(this);
if (similar != null){
detach(Dungeon.hero.belongings.backpack);
return similar.merge(this);
}
updateQuickslot();
return this;
}
} else {
return super.upgrade();
}
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
actions.remove( AC_EQUIP );
return actions;
}
@Override
public boolean collect(Bag container) {
if (container instanceof MagicalHolster) holster = true;
return super.collect(container);
}
@Override
public int throwPos(Hero user, int dst) {
if (hasEnchant(Projecting.class, user)
&& !Dungeon.level.solid[dst] && Dungeon.level.distance(user.pos, dst) <= 4){
return dst;
} else {
return super.throwPos(user, dst);
}
}
@Override
public void doThrow(Hero hero) {
parent = null; //reset parent before throwing, just incase
super.doThrow(hero);
}
@Override
protected void onThrow( int cell ) {
Char enemy = Actor.findChar( cell );
if (enemy == null || enemy == curUser) {
parent = null;
super.onThrow( cell );
} else {
if (!curUser.shoot( enemy, this )) {
rangedMiss( cell );
} else {
rangedHit( enemy, cell );
}
}
}
@Override
public Item random() {
if (!stackable) return this;
//2: 66.67% (2/3)
//3: 26.67% (4/15)
//4: 6.67% (1/15)
quantity = 2;
if (Random.Int(3) == 0) {
quantity++;
if (Random.Int(5) == 0) {
quantity++;
}
}
return this;
}
@Override
public float castDelay(Char user, int dst) {
return speedFactor( user );
}
protected void rangedHit( Char enemy, int cell ){
decrementDurability();
if (durability > 0){
//attempt to stick the missile weapon to the enemy, just drop it if we can't.
if (sticky && enemy != null && enemy.isAlive() && enemy.buff(Corruption.class) == null){
PinCushion p = Buff.affect(enemy, PinCushion.class);
if (p.target == enemy){
p.stick(this);
return;
}
}
Dungeon.level.drop( this, cell ).sprite.drop();
}
}
protected void rangedMiss( int cell ) {
parent = null;
super.onThrow(cell);
}
protected float durabilityPerUse(){
float usages = baseUses * (float)(Math.pow(3, level()));
if (Dungeon.hero.heroClass == HeroClass.HUNTRESS) usages *= 1.5f;
if (holster) usages *= MagicalHolster.HOLSTER_DURABILITY_FACTOR;
usages *= RingOfSharpshooting.durabilityMultiplier( Dungeon.hero );
//at 100 uses, items just last forever.
if (usages >= 100f) return 0;
//add a tiny amount to account for rounding error for calculations like 1/3
return (MAX_DURABILITY/usages) + 0.001f;
}
protected void decrementDurability(){
//if this weapon was thrown from a source stack, degrade that stack.
//unless a weapon is about to break, then break the one being thrown
if (parent != null){
if (parent.durability <= parent.durabilityPerUse()){
durability = 0;
parent.durability = MAX_DURABILITY;
} else {
parent.durability -= parent.durabilityPerUse();
if (parent.durability > 0 && parent.durability <= parent.durabilityPerUse()){
if (level() <= 0)GLog.w(Messages.get(this, "about_to_break"));
else GLog.n(Messages.get(this, "about_to_break"));
}
}
parent = null;
} else {
durability -= durabilityPerUse();
if (durability > 0 && durability <= durabilityPerUse()){
if (level() <= 0)GLog.w(Messages.get(this, "about_to_break"));
else GLog.n(Messages.get(this, "about_to_break"));
}
}
}
@Override
public int damageRoll(Char owner) {
int damage = augment.damageFactor(super.damageRoll( owner ));
if (owner instanceof Hero) {
int exStr = ((Hero)owner).STR() - STRReq();
if (exStr > 0) {
damage += Random.IntRange( 0, exStr );
}
}
return damage;
}
@Override
public void reset() {
super.reset();
durability = MAX_DURABILITY;
}
@Override
public Item merge(Item other) {
super.merge(other);
if (isSimilar(other)) {
durability += ((MissileWeapon)other).durability;
durability -= MAX_DURABILITY;
while (durability <= 0){
quantity -= 1;
durability += MAX_DURABILITY;
}
}
return this;
}
@Override
public Item split(int amount) {
bundleRestoring = true;
Item split = super.split(amount);
bundleRestoring = false;
//unless the thrown weapon will break, split off a max durability item and
//have it reduce the durability of the main stack. Cleaner to the player this way
if (split != null){
MissileWeapon m = (MissileWeapon)split;
m.durability = MAX_DURABILITY;
m.parent = this;
}
return split;
}
@Override
public boolean doPickUp(Hero hero) {
parent = null;
return super.doPickUp(hero);
}
@Override
public boolean isIdentified() {
return true;
}
@Override
public String info() {
String info = desc();
info += "\n\n" + Messages.get( MissileWeapon.class, "stats",
tier,
Math.round(augment.damageFactor(min())),
Math.round(augment.damageFactor(max())),
STRReq());
if (STRReq() > Dungeon.hero.STR()) {
info += " " + Messages.get(Weapon.class, "too_heavy");
} else if (Dungeon.hero.STR() > STRReq()){
info += " " + Messages.get(Weapon.class, "excess_str", Dungeon.hero.STR() - STRReq());
}
if (enchantment != null && (cursedKnown || !enchantment.curse())){
info += "\n\n" + Messages.get(Weapon.class, "enchanted", enchantment.name());
info += " " + Messages.get(enchantment, "desc");
}
if (cursed && isEquipped( Dungeon.hero )) {
info += "\n\n" + Messages.get(Weapon.class, "cursed_worn");
} else if (cursedKnown && cursed) {
info += "\n\n" + Messages.get(Weapon.class, "cursed");
} else if (!isIdentified() && cursedKnown){
info += "\n\n" + Messages.get(Weapon.class, "not_cursed");
}
info += "\n\n" + Messages.get(MissileWeapon.class, "distance");
info += "\n\n" + Messages.get(this, "durability");
if (durabilityPerUse() > 0){
info += " " + Messages.get(this, "uses_left",
(int)Math.ceil(durability/durabilityPerUse()),
(int)Math.ceil(MAX_DURABILITY/durabilityPerUse()));
} else {
info += " " + Messages.get(this, "unlimited_uses");
}
return info;
}
@Override
public int price() {
return 6 * tier * quantity * (level() + 1);
}
private static final String DURABILITY = "durability";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(DURABILITY, durability);
}
private static boolean bundleRestoring = false;
@Override
public void restoreFromBundle(Bundle bundle) {
bundleRestoring = true;
super.restoreFromBundle(bundle);
bundleRestoring = false;
durability = bundle.getInt(DURABILITY);
}
}
| 10,731 | MissileWeapon | java | en | java | code | {"qsc_code_num_words": 1267, "qsc_code_num_chars": 10731.0, "qsc_code_mean_word_length": 5.6961326, "qsc_code_frac_words_unique": 0.25493291, "qsc_code_frac_chars_top_2grams": 0.03879728, "qsc_code_frac_chars_top_3grams": 0.08951088, "qsc_code_frac_chars_top_4grams": 0.09754746, "qsc_code_frac_chars_dupe_5grams": 0.21158376, "qsc_code_frac_chars_dupe_6grams": 0.14839961, "qsc_code_frac_chars_dupe_7grams": 0.07122073, "qsc_code_frac_chars_dupe_8grams": 0.05376195, "qsc_code_frac_chars_dupe_9grams": 0.02549536, "qsc_code_frac_chars_dupe_10grams": 0.02549536, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01184119, "qsc_code_frac_chars_whitespace": 0.19727891, "qsc_code_size_file_byte": 10731.0, "qsc_code_num_lines": 388.0, "qsc_code_num_chars_line_max": 106.0, "qsc_code_num_chars_line_mean": 27.65721649, "qsc_code_frac_chars_alphabet": 0.82598096, "qsc_code_frac_chars_comments": 0.15823316, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.18685121, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.02258386, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.00257732, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.09342561, "qsc_codejava_score_lines_no_logic": 0.20761246, "qsc_codejava_frac_words_no_modifier": 0.96296296, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": null, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Annoying.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Random;
public class Annoying extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc( Weapon weapon, Char attacker, Char defender, int damage ) {
if (Random.Int(20) == 0) {
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
mob.beckon(attacker.pos);
}
attacker.sprite.centerEmitter().start(Speck.factory(Speck.SCREAM), 0.3f, 3);
Sample.INSTANCE.play(Assets.SND_MIMIC);
Invisibility.dispel();
GLog.n(Messages.get(this, "msg_" + (Random.Int(5)+1)));
}
return damage;
}
@Override
public boolean curse() {
return true;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
} | 2,274 | Annoying | java | en | java | code | {"qsc_code_num_words": 290, "qsc_code_num_chars": 2274.0, "qsc_code_mean_word_length": 6.04137931, "qsc_code_frac_words_unique": 0.50689655, "qsc_code_frac_chars_top_2grams": 0.06164384, "qsc_code_frac_chars_top_3grams": 0.23858447, "qsc_code_frac_chars_top_4grams": 0.25114155, "qsc_code_frac_chars_dupe_5grams": 0.18835616, "qsc_code_frac_chars_dupe_6grams": 0.03196347, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01675978, "qsc_code_frac_chars_whitespace": 0.13412489, "qsc_code_size_file_byte": 2274.0, "qsc_code_num_lines": 66.0, "qsc_code_num_chars_line_max": 80.0, "qsc_code_num_chars_line_mean": 34.45454545, "qsc_code_frac_chars_alphabet": 0.873032, "qsc_code_frac_chars_comments": 0.34344767, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.08108108, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00267738, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00535475, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.05405405, "qsc_codejava_score_lines_no_logic": 0.48648649, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/curses/Friendly.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Charm;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Friendly extends Weapon.Enchantment {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc(Weapon weapon, Char attacker, Char defender, int damage ) {
if (Random.Int(10) == 0){
int base = Random.IntRange(3, 5);
Buff.affect( attacker, Charm.class, base + 10 ).object = defender.id();
attacker.sprite.centerEmitter().start( Speck.factory( Speck.HEART ), 0.2f, 5 );
//5 turns will be reduced by the attack, so effectively lasts for base turns
Buff.affect( defender, Charm.class, base + 5 ).object = attacker.id();
defender.sprite.centerEmitter().start( Speck.factory( Speck.HEART ), 0.2f, 5 );
}
return damage;
}
@Override
public boolean curse() {
return true;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
}
| 2,142 | Friendly | java | en | java | code | {"qsc_code_num_words": 281, "qsc_code_num_chars": 2142.0, "qsc_code_mean_word_length": 5.68327402, "qsc_code_frac_words_unique": 0.4911032, "qsc_code_frac_chars_top_2grams": 0.07451472, "qsc_code_frac_chars_top_3grams": 0.1665623, "qsc_code_frac_chars_top_4grams": 0.16530996, "qsc_code_frac_chars_dupe_5grams": 0.27551659, "qsc_code_frac_chars_dupe_6grams": 0.1665623, "qsc_code_frac_chars_dupe_7grams": 0.06261741, "qsc_code_frac_chars_dupe_8grams": 0.06261741, "qsc_code_frac_chars_dupe_9grams": 0.06261741, "qsc_code_frac_chars_dupe_10grams": 0.06261741, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02172702, "qsc_code_frac_chars_whitespace": 0.16199813, "qsc_code_size_file_byte": 2142.0, "qsc_code_num_lines": 65.0, "qsc_code_num_chars_line_max": 83.0, "qsc_code_num_chars_line_mean": 32.95384615, "qsc_code_frac_chars_alphabet": 0.86796657, "qsc_code_frac_chars_comments": 0.39962652, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.1, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00622084, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.43333333, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/ParalyticDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class ParalyticDart extends TippedDart {
{
image = ItemSpriteSheet.PARALYTIC_DART;
}
@Override
public int proc( Char attacker, Char defender, int damage ) {
Buff.prolong( defender, Paralysis.class, 5f );
return super.proc( attacker, defender, damage );
}
}
| 1,416 | ParalyticDart | java | en | java | code | {"qsc_code_num_words": 186, "qsc_code_num_chars": 1416.0, "qsc_code_mean_word_length": 5.84946237, "qsc_code_frac_words_unique": 0.59677419, "qsc_code_frac_chars_top_2grams": 0.078125, "qsc_code_frac_chars_top_3grams": 0.17463235, "qsc_code_frac_chars_top_4grams": 0.16176471, "qsc_code_frac_chars_dupe_5grams": 0.22242647, "qsc_code_frac_chars_dupe_6grams": 0.15257353, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01506276, "qsc_code_frac_chars_whitespace": 0.15607345, "qsc_code_size_file_byte": 1416.0, "qsc_code_num_lines": 40.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 35.4, "qsc_code_frac_chars_alphabet": 0.89539749, "qsc_code_frac_chars_comments": 0.55155367, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.4, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/ShockingDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.Lightning;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
import java.util.ArrayList;
public class ShockingDart extends TippedDart {
{
image = ItemSpriteSheet.SHOCKING_DART;
}
@Override
public int proc(Char attacker, Char defender, int damage) {
defender.damage(Random.NormalIntRange(8, 12), this);
CharSprite s = defender.sprite;
if (s != null && s.parent != null) {
ArrayList<Lightning.Arc> arcs = new ArrayList<>();
arcs.add(new Lightning.Arc(new PointF(s.x, s.y + s.height / 2), new PointF(s.x + s.width, s.y + s.height / 2)));
arcs.add(new Lightning.Arc(new PointF(s.x + s.width / 2, s.y), new PointF(s.x + s.width / 2, s.y + s.height)));
s.parent.add(new Lightning(arcs, null));
Sample.INSTANCE.play( Assets.SND_LIGHTNING );
}
return super.proc(attacker, defender, damage);
}
}
| 2,065 | ShockingDart | java | en | java | code | {"qsc_code_num_words": 289, "qsc_code_num_chars": 2065.0, "qsc_code_mean_word_length": 5.30795848, "qsc_code_frac_words_unique": 0.48096886, "qsc_code_frac_chars_top_2grams": 0.04693611, "qsc_code_frac_chars_top_3grams": 0.14863103, "qsc_code_frac_chars_top_4grams": 0.14341591, "qsc_code_frac_chars_dupe_5grams": 0.20599739, "qsc_code_frac_chars_dupe_6grams": 0.11016949, "qsc_code_frac_chars_dupe_7grams": 0.06258149, "qsc_code_frac_chars_dupe_8grams": 0.06258149, "qsc_code_frac_chars_dupe_9grams": 0.06258149, "qsc_code_frac_chars_dupe_10grams": 0.04432855, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01370645, "qsc_code_frac_chars_whitespace": 0.15205811, "qsc_code_size_file_byte": 2065.0, "qsc_code_num_lines": 57.0, "qsc_code_num_chars_line_max": 116.0, "qsc_code_num_chars_line_mean": 36.22807018, "qsc_code_frac_chars_alphabet": 0.86236436, "qsc_code_frac_chars_comments": 0.37820823, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.03571429, "qsc_codejava_score_lines_no_logic": 0.39285714, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/ChillingDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class ChillingDart extends TippedDart {
{
image = ItemSpriteSheet.CHILLING_DART;
}
@Override
public int proc(Char attacker, Char defender, int damage) {
if (Dungeon.level.water[defender.pos]){
Buff.prolong(defender, Chill.class, 10f);
} else {
Buff.prolong(defender, Chill.class, 6f);
}
return super.proc(attacker, defender, damage);
}
}
| 1,565 | ChillingDart | java | en | java | code | {"qsc_code_num_words": 204, "qsc_code_num_chars": 1565.0, "qsc_code_mean_word_length": 5.85784314, "qsc_code_frac_words_unique": 0.56862745, "qsc_code_frac_chars_top_2grams": 0.08535565, "qsc_code_frac_chars_top_3grams": 0.19079498, "qsc_code_frac_chars_top_4grams": 0.18410042, "qsc_code_frac_chars_dupe_5grams": 0.25104603, "qsc_code_frac_chars_dupe_6grams": 0.13891213, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01510574, "qsc_code_frac_chars_whitespace": 0.15399361, "qsc_code_size_file_byte": 1565.0, "qsc_code_num_lines": 47.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 33.29787234, "qsc_code_frac_chars_alphabet": 0.88746224, "qsc_code_frac_chars_comments": 0.49904153, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.05, "qsc_codejava_score_lines_no_logic": 0.35, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/darts/TippedDart.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.PinCushion;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Blindweed;
import com.shatteredpixel.shatteredpixeldungeon.plants.Dreamfoil;
import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot;
import com.shatteredpixel.shatteredpixeldungeon.plants.Fadeleaf;
import com.shatteredpixel.shatteredpixeldungeon.plants.Firebloom;
import com.shatteredpixel.shatteredpixeldungeon.plants.Icecap;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
import com.shatteredpixel.shatteredpixeldungeon.plants.Rotberry;
import com.shatteredpixel.shatteredpixeldungeon.plants.Sorrowmoss;
import com.shatteredpixel.shatteredpixeldungeon.plants.Starflower;
import com.shatteredpixel.shatteredpixeldungeon.plants.Stormvine;
import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass;
import com.shatteredpixel.shatteredpixeldungeon.plants.Swiftthistle;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.utils.Reflection;
import java.util.ArrayList;
import java.util.HashMap;
public abstract class TippedDart extends Dart {
{
tier = 2;
//so that slightly more than 1.5x durability is needed for 2 uses
baseUses = 0.65f;
}
private static final String AC_CLEAN = "CLEAN";
@Override
public ArrayList<String> actions(Hero hero) {
ArrayList<String> actions = super.actions( hero );
actions.remove( AC_TIP );
actions.add( AC_CLEAN );
return actions;
}
@Override
public void execute(final Hero hero, String action) {
if (action.equals( AC_CLEAN )){
GameScene.show(new WndOptions(Messages.get(this, "clean_title"),
Messages.get(this, "clean_desc"),
Messages.get(this, "clean_all"),
Messages.get(this, "clean_one"),
Messages.get(this, "cancel")){
@Override
protected void onSelect(int index) {
if (index == 0){
detachAll(hero.belongings.backpack);
new Dart().quantity(quantity).collect();
hero.spend( 1f );
hero.busy();
hero.sprite.operate(hero.pos);
} else if (index == 1){
detach(hero.belongings.backpack);
if (!new Dart().collect()) Dungeon.level.drop(new Dart(), hero.pos).sprite.drop();
hero.spend( 1f );
hero.busy();
hero.sprite.operate(hero.pos);
}
}
});
}
super.execute(hero, action);
}
//exact same damage as regular darts, despite being higher tier.
@Override
protected void rangedHit(Char enemy, int cell) {
super.rangedHit( enemy, cell);
//need to spawn a dart
if (durability <= 0){
//attempt to stick the dart to the enemy, just drop it if we can't.
Dart d = new Dart();
if (enemy.isAlive() && sticky) {
PinCushion p = Buff.affect(enemy, PinCushion.class);
if (p.target == enemy){
p.stick(d);
return;
}
}
Dungeon.level.drop( d, enemy.pos ).sprite.drop();
}
}
@Override
protected float durabilityPerUse() {
float use = super.durabilityPerUse();
if (Dungeon.hero.subClass == HeroSubClass.WARDEN){
use /= 2f;
}
return use;
}
@Override
public int price() {
//value of regular dart plus half of the seed
return 8 * quantity;
}
private static HashMap<Class<?extends Plant.Seed>, Class<?extends TippedDart>> types = new HashMap<>();
static {
types.put(Blindweed.Seed.class, BlindingDart.class);
types.put(Dreamfoil.Seed.class, SleepDart.class);
types.put(Earthroot.Seed.class, ParalyticDart.class);
types.put(Fadeleaf.Seed.class, DisplacingDart.class);
types.put(Firebloom.Seed.class, IncendiaryDart.class);
types.put(Icecap.Seed.class, ChillingDart.class);
types.put(Rotberry.Seed.class, RotDart.class);
types.put(Sorrowmoss.Seed.class, PoisonDart.class);
types.put(Starflower.Seed.class, HolyDart.class);
types.put(Stormvine.Seed.class, ShockingDart.class);
types.put(Sungrass.Seed.class, HealingDart.class);
types.put(Swiftthistle.Seed.class, AdrenalineDart.class);
}
public static TippedDart getTipped( Plant.Seed s, int quantity ){
return (TippedDart) Reflection.newInstance(types.get(s.getClass())).quantity(quantity);
}
public static TippedDart randomTipped( int quantity ){
Plant.Seed s;
do{
s = (Plant.Seed) Generator.random(Generator.Category.SEED);
} while (!types.containsKey(s.getClass()));
return getTipped(s, quantity );
}
}
| 5,802 | TippedDart | java | en | java | code | {"qsc_code_num_words": 696, "qsc_code_num_chars": 5802.0, "qsc_code_mean_word_length": 6.12787356, "qsc_code_frac_words_unique": 0.34913793, "qsc_code_frac_chars_top_2grams": 0.09566237, "qsc_code_frac_chars_top_3grams": 0.21383353, "qsc_code_frac_chars_top_4grams": 0.23728019, "qsc_code_frac_chars_dupe_5grams": 0.25463072, "qsc_code_frac_chars_dupe_6grams": 0.08440797, "qsc_code_frac_chars_dupe_7grams": 0.02016413, "qsc_code_frac_chars_dupe_8grams": 0.02016413, "qsc_code_frac_chars_dupe_9grams": 0.02016413, "qsc_code_frac_chars_dupe_10grams": 0.02016413, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00631107, "qsc_code_frac_chars_whitespace": 0.15339538, "qsc_code_size_file_byte": 5802.0, "qsc_code_num_lines": 172.0, "qsc_code_num_chars_line_max": 105.0, "qsc_code_num_chars_line_mean": 33.73255814, "qsc_code_frac_chars_alphabet": 0.86197068, "qsc_code_frac_chars_comments": 0.17993795, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.09917355, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01050862, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.07438017, "qsc_codejava_score_lines_no_logic": 0.32231405, "qsc_codejava_frac_words_no_modifier": 0.7, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.